Mysterious Double Post Back/Page Request

Recently I run into a strange situation that one of my pages was always loaded twice for each reqeust. This happened only when I enable  “URL Rewrite” feature for the site.  After almost a hour of debugging, I found it’s caused by a line in stylesheet like this:


In a regular, non-URLRewrite case, the broswer will correctly render the relative location of this image from the web page, which is at the root folder. It will resolve the location of mypic.gif to be /images/mypic.gif.

However, when URL rewrite was turned on, my page’s URL changed from /JobDetails.aspx?id=123 to /Jobs/Orange County/IT/123/Web Designer Needed. For the broswer, the page is located at many levels deep from the root. As the result, the path of above image will be resolved to /Jobs/Orange+County/IT/123/Web+Designer Needed/images/mypic.gif.

The retrieval of the image is a separate GET HTTP request from the broswer. Unfortunately, the URL of the image happens to match one of the URL rewrite rules. The result: this image request gets to translated to /JobDetails.aspx?id=123 and this ASPX page is requested twice!

Lesson: always use absolute path, espacially when URL rewrite is used.

This entry was posted in ASP.NET and tagged . Bookmark the permalink.

2 Responses to Mysterious Double Post Back/Page Request

  1. Amit says:

    Could you tell me how you have done url rewriting in sharepoint. I hve done the same thing but facing problem in postback wheneva I m trying to click on any link in sharepoint. It is giving back the original url not the virtual url I want.

    Any help would really be appreciated.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s