URL Rewrite 2.0 Rule can prevent Images from displaying on WebControls like TreeView
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 https://mysite/treepage.aspx?nodeName=RedColors to https://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="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
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="^([^/]+)/?$" />
<conditions>
<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$" />
</conditions>
Please let me know if you found this Post useful and if it solved your problem!