Jeff Sanders Technical Blog

I am a Microsoft employee that has worked on all aspects of the Web Stack for a long time. I hope these blogs are useful to you! Use this information at your own risk.


<< Go Back

Url Rewrite 2 0 Rule Can Prevent Images From Displaying On Webcontrols Like Treeview

- 19 Mar 2010

I was excited to try URL Rewrite to create some rules on my internal web site.  I added a rule to map a query string like http://mysite/treepage.aspx?nodeName=RedColors to http://mysite/RedColors .  After doing this I found that the images of the treeview web control now did not display.  I enabled FREB tracing and found that this rule was translating webresource.axd improperly:

<rule name=”RewriteUserFriendlyURL1″ stopProcessing=”true”>
  <match url=”^([^/]+)/?$” />
 
    <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
    <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</samp>

RequestURL    http://mysite:80/WebResource.axd?d=zGZU6qcW6fzAgYe-oI85v1qoiSgWelpv1EkImgNZdKA1&t=633802488069218315

RequestURL    http://mysite:80/treepage.aspx?nodeName=WebResource.axd&d=zGZU6qcW6fzAgYe-oI85v1qoiSgWelpv1EkImgNZdKA1&t=633802488069218315

Since the rule saw the ‘?’ char it was trying to map it.

To solve this add a rule to exclude processing of .axd files:

<rule name=”RewriteUserFriendlyURL1″ stopProcessing=”true”>
  <match url=”^([^/]+)/?$” />
 
    <add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
    <add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
    <!–  The following condition prevents rule from rewriting requests to .axd files –>
    <add input=”{URL}” negate=”true” pattern=”\.axd$” />
 

 

Please let me know if you found this Post useful and if it solved your problem!

<< Go Back