Eyl 12 2009

Prevent URL Rewriting of Requests for ASP.NET-WebResources.axd

Category: Ajax | ASP.NETLatif @ 14:50

Hi again,

 WebResources.axd is created by ASP.NET for performing AJAX processes in the page. İn Addition, there is no such file on the web server due to the fact that ASP.NET produce the content dynamically when WebResources.axd is requested.


If you want to see the content of WebResources.axd, you have to run it on browser. Script path is in the page source code like below,


<script src="/WebResource.axd?d=7OCAQ3R3VOQC0D4ciLQ5OCpSc8_wxlQ0C-KYhGZ-_ag1&amp;t=633566872339565967" type="text/javascript"></script>


İf you are using Url Rewring, URL rewrite rule may accidentally make the requests to WebResources.axd and this will break your application.


Anyway, in order to prevent URL Rewriting of Requests for ASP.NET Web Resources(.axd) and other type of files such as .xml,.js,.css , you should add rule to web.config.


     <rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.xml|\.pdf|\.axd|\.css|\.js)(\?.+)?)$" to="$1" processing="stop" />

     <rewrite url="/([0-9]{6})(.*)/(.*)-(.*)" to="~/Detail.aspx?aid=$1" />



The problem can be easily prevented by this rule.


Have a good time...



Weird Stories Weird Stories United States says:

thanks for your articles, if you do not mind I want to post your article on my blog

Latif OZTURK Latif OZTURK Turkey says:

Sure, you can post my articles on your blog provided that you show the reference.

Freddy Freddy Malaysia says:

GREAT!! You safe me...

chat script chat script United States says:

I really appreciate posts, which might be of very useful for beginners in blogging as I am. I already have a small collection of blog posts and other articles, from which I step by step learn various aspects of life. Thank you for your resource.