One gotcha that people often run into when using ASP.NET and
Url-Rewriting has to-do with handling postback scenarios. Specifically,
when you place a <form runat="server"> control on a page,
ASP.NET will automatically by default output the "action" attribute
of the markup to point back to the page it is on. The problem when
using URL-Rewriting is that the URL that the <form> control
renders is not the original URL of the request (for example: /products/books),
but rather the re-written one (for example:
/products.aspx?category=books). This means that when you do a postback to
the server, the URL will not be your nice clean one.
With ASP.NET 1.0 and 1.1, people often resorted to
sub-classing the <form> control and created their own control that correctly
output the action to use. While this works, it ends up being a little
messy - since it means you have to update all of your pages to use this
alternate form control, and it can sometimes have problems with the Visual
Studio WYSIWYG designer.
The good news is that with ASP.NET 2.0, there is a cleaner
trick that you can use to rewrite the "action" attribute on the
<form> control. Specifically, you can take advantage of the new ASP.NET 2.0 Control Adapter extensibility architecture to
customize the rendering of the <form> control, and override its
"action" attribute value with a value you provide. This doesn't
require you to change any code in your .aspx pages. Instead, just add a
.browser file to your /app_browsers folder that registers a Control Adapter
class to use to output the new "action" attribute:
Figure 1

You can see a sample implementation I created that shows how to implement a Form Control Adapter that works with
URLRewriting in my sample here. It works for both the
Request.PathInfo and UrlRewriter.Net module approaches I used in Approach 1 and
2 above, and uses the Request.RawUrl property to retrieve the original,
un-rewritten, URL to render. With the ISAPIRewrite filter in Approach 4
you can retrieve the Request.ServerVariables["HTTP_X_REWRITE_URL"]
value that the ISAPI filter uses to save the original URL instead.
My FormRewriter class implementation above should work for
both standard ASP.NET and ASP.NET AJAX 1.0 pages (let me know if you run into
any issues).