Last week I had done a post on how to rewrite URLs using the URLRewriter.Net component. You can read it here . Another issue that comes up while using URL rewriting in ASP.NET is the problem of postbacks. Whenever a postback occurs in the page, you find that after the postback the URL in the address bar of the browser shows your ugly URL again which you were trying so hard to hide . You can test it out here in my website Christian-Jokes.net (I’ll be fixing it soon though ). Go to any joke and check the URL in your browser . You will see the friendly URL. Now write down a short comment for the joke and submit the comment. After the comment is submitted, you see that the URL in the browser has changed to something like this “ShowJoke.aspx?JokeID=123″ .
Thankfully, again the the guys at URLrewriter.Net has a simple solution for us, though it took me some time to find it . Add the following code at the top of your page
<%@ Register TagPrefix="url" Namespace="Intelligencia.UrlRewriter"
and then change your form tag from <asp:form runat=”server”> to <url:form runat=”server”>
If you are using master pages, you will most probably add the above lines in your master page file