ASP.NET 4.0 URL routing 404 problems with IIS7

As I described before, I love the new routing feature in ASP.NET 4.0.  I succesfully converted my code from Intelligencia over to the built in routing.  The site ran great locally, but when I deployed to IIS7, I got 404's on every page that didn't have an extension.  Those pages were my routed product pages.

Some googling led to to add a line to my web.config file.  Here is is:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

This apparently forces IIS to invoke the routing module.  I found no mention of this anywhere and was under the assumption I didn't have to modify any config files.  Hope this helps somebody.

Here are some sources where I found this:

http://forums.asp.net/t/1523639.aspx
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

Comments (9) -

5/5/2010 1:22:07 PM #

Eric

This saved me a ton of time - thank you.  

Eric | Reply

5/5/2010 1:25:23 PM #

Scott

Great to hear Smile  

Scott | Reply

5/20/2010 12:07:40 AM #

Gilad

saved my day!  this post shuld be on the front page of the iis 7 site Smile

scott , you are the man

Gilad | Reply

8/19/2010 6:46:44 AM #

Pragnesh

hi gildner,
i have tried solution as you shown above but it is not working for me.
my url is :    https://www.mysite.com/news/1/test-news
which is not working but if i add .aspx at the end then it works.
https://www.mysite.com/news/1/test-news.aspx

Was there anything else to set?

thanks
Pragnesh

Pragnesh | Reply

9/10/2010 8:57:35 AM #

Scott

Pragnesh,

Make sure you have your URL mapped like in this post:

www.gildnersolutions.com/.../...0-URL-routing.aspx

It's a little tricky, but once you get it working, it's great.  Good luck,
Scott

Scott | Reply

9/13/2010 12:08:45 AM #

pragnesh

hi scott,
thanks for reply.
i was figured out the problem.
It was with Application Pool.
I was set it to classic asp.net 4.0 application pool. which was causing problem.
by setting normatl asp.net 4.0 app pool it is working.

Pragnesh

pragnesh | Reply

10/28/2010 11:17:17 AM #

Daniel

Unfortunately this configuration slows down the performance of static-content-processing (.jpg, .js, etc).
The reason why the routing does not work on your machine without this configuration is, that by default IIS redirects the requests to unmanaged modules. You just force IIS to redirect all requests to managed modules, so that the asp.net routing-module will be called.

An alternative and a detail explanation can be found here:
blogs.msdn.com/.../...pacting-static-requests.aspx

In short, you must install this hotfix for IIS7 and then it will also work without this configuration (and performance-loss): http://support.microsoft.com/kb/980368

Daniel | Reply

2/26/2011 7:09:05 PM #

steve

Thank you so much - I almost punched my machine after 2 hours of nonsense 404 errors - much appreciated sharing your knowledge on this...

Steve

steve United Kingdom | Reply

2/26/2011 10:15:47 PM #

scott

great to hear!

scott United States | Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading