Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

ASP.NET Routing not working on IIS 7.0

On this page:

I ran into a nasty little problem today when deploying an application using ASP.NET 4.0 Routing to my live server. The application and its Routing were working just fine on my dev machine (Windows 7 and IIS 7.5), but when I deployed (Windows 2008 R1 and IIS 7.0) Routing would just not work. Every time I hit a routed url IIS would just throw up a 404 error:


This is an IIS error, not an ASP.NET error so this doesn’t actually come from ASP.NET’s routing engine but from IIS’s handling of expressionless URLs. Note that it’s clearly falling through all the way to the StaticFile handler which is the last handler to fire in the typical IIS handler list. In other words IIS is trying to parse the extension less URL and not firing it into ASP.NET but failing.

As I mentioned on my local machine this all worked fine and to make sure local and live setups match I re-copied my Web.config, double checked handler mappings in IIS and re-copied the actual application assemblies to the server. It all looked exactly matched. However no workey on the server with IIS 7.0!!!

Finally, totally by chance, I remembered the runAllManagedModulesForAllRequests attribute flag on the modules key in web.config and set it to true:

    <modules runAllManagedModulesForAllRequests="true">
      <add name="ScriptCompressionModule" type="Westwind.Web.ScriptCompressionModule,Westwind.Web" />

And lo and behold, Routing started working on the live server and IIS 7.0!

This seems really obvious now of course, but the really tricky thing about this is that on IIS 7.5 this key is not necessary. So on my Windows 7 machine ASP.NET Routing was working just fine without the key set. However on IIS 7.0 on my live server the same missing setting was not working. On IIS 7.0 this key must be present or Routing will not work.

Oddly on IIS 7.5 it appears that you can’t even turn off the behavior – setting runtAllManagedModuleForAllRequests="false" had no effect at all and Routing continued to work just fine even with the flag set to false, which is NOT what I would have expected.

Kind of disappointing too that Windows Server 2008 (R1) can’t be upgraded to IIS 7.5. It sure seems like that should have been possible since the OS server core changes in R2 are pretty minor. For the future I really hope Microsoft will allow updating IIS versions without tying them explicitly to the OS. It looks like that with the release of IIS Express Microsoft has taken some steps to untie some of those tight OS links from IIS. Let’s hope that’s the case for the future – it sure is nice to run the same IIS version on dev and live boxes, but upgrading live servers is too big a deal to do just because an updated OS release came out.

Moral of the story – never assume that your dev setup will work as is on the live setup. It took me forever to figure this out because I assumed that because my web.config on the local machine was fine and working and I copied all relevant web.config data to the server it can’t be the configuration settings. I was looking everywhere but in the .config file forever before getting desperate and remembering the flag when I accidentally checked the intellisense settings in the modules key.

Never assume anything. The other moral is: Try to keep your dev machine and server OS’s in sync whenever possible. Maybe it’s time to upgrade to Windows Server 2008 R2 after all.

More info on Extensionless URLs in IIS

Want to find out more exactly on how extensionless Urls work on IIS 7? The check out  How ASP.NET MVC Routing Works and its Impact on the Performance of Static Requests which goes into great detail on the complexities of the process. Thanks to Jeff Graves for pointing me at this article – a great linked reference for this topic!

Posted in IIS7  Windows  

The Voices of Reason


March 28, 2011

# re: ASP.NET Routing not working on IIS 7.0

Hi Rick,

I have got same problem on server. Probably this was because you are using MVC/ Routing in ASP.NET 4.0.
My problem was solved mere by changing Appllication pool to ASP.NET 4.0 for that website/application & restarting site on IIS.

Hope it can work at other side too.

March 28, 2011

# re: ASP.NET Routing not working on IIS 7.0

You should also be aware of this issue on IIS7.5 which I reported to PSS what seems like a month of Sundays ago (which eventually triggered this KB article):


As a web hoster this really buggered things up for us and is still unresolved :(.

Bob Miner
April 22, 2011

# re: ASP.NET Routing not working on IIS 7.0

THANKS RICK! I had a web site built with an early version of ASP.NET MVC 3 and the web.config files didn't have this entry. Adding it fixed the problem. It was odd though that the problem didn't show up until a recent Windows Update. Thanks again.

May 31, 2011

# re: ASP.NET Routing not working on IIS 7.0

Hi Rick. I wanted to comment on this statement in bold above:
"On IIS 7.0 this key must be present or Routing will not work"

We found that this setting is not required to get routing working in Server 2008 IIS 7.0. Originally we did have runAllManagedModulesForAllRequests="true" and Routing was working, then we found this post about why using that setting is not a good idea:


We found that if we applied KB980368 (requires Windows Server 2008 SP2) we could get Routing to work without relying on runAllManagedModulesForAllRequests.

Rick Strahl
May 31, 2011

# re: ASP.NET Routing not working on IIS 7.0

@txCraig - Part of the the issue is that this behavior has changed many times. Original IIS 7 RTM in integrated routed all requests through managed code. Then it was turned off in an update, then the configuration switch was changed in IIS 7.5. Now there's a KB and patch that give yet more options.

Unless your site(s) are super critical in terms of resource usage, I'd say the overhead of having all requests going through the module pipeline is not that critical. Other than initial startup slowness for an ApplicationPool and first access performance is not likely to have more than a fractional percentage impact. I suppose it depends on your app and what module filtering occurs on requests, but if we're talking only about the routing module (and default ASP.NET pipeline modules) the overhead is really small. Plus IIS caching will override for a lot of requests served from disk.

September 03, 2011

# re: ASP.NET Routing not working on IIS 7.0

you can try by adding a new httphandler mapping on the specific website in IIS 7.5 for your desired choice of path format. Make sure to put this new entry at a proper index in the ordered list of handler entries.

James McCormack
January 27, 2012

# re: ASP.NET Routing not working on IIS 7.0

txcraig - You rock, we couldn't find information about that KB hotfix anywhere! Solved our MVC 3 problem with 404 errors on Windows Server 2008 (non R2).

August 07, 2012

# re: ASP.NET Routing not working on IIS 7.0

Thanks Rick.
You da man! I was trying to figure out the same thing. I assumed that the 2008 was running 7.5 as well and all was identical, but apparently not.

September 25, 2012

# re: ASP.NET Routing not working on IIS 7.0

I got the same trouble today on IIS7.0 / not affecting IIS7.5.
Found the following KB: http://support.microsoft.com/kb/980368
I installed the fix in the KB (which requires an OS restart).
It fixed the problem for us.

October 04, 2012

# re: ASP.NET Routing not working on IIS 7.0

When all else fails, this also occurs when adding a .NET 4.0 MVC "app" under a .NET 2.0 parent Web Site (ex. "Default Web Site"). There doesn't seem to be a good way to run a mix of 2.0/3.5/4.0 sites under different top-level parent sites. For example, if your top-level site is 2.0, then 4.0 apps break. If your top-level is 4.0, then 2.0 apps under that site break.

February 20, 2013

# re: ASP.NET Routing not working on IIS 7.0

This also drove me crazy yesterday. And with me it was the other way around. Worked well on Windows Server 2008. But failed to work on Windows 7. Both IIS 7.5.

I think it's because on Windows Server 2008 (my development machine), Visual Studio already applies the patch or does something else that makes it work. On the Windows 7 machine that did NOT have Visual Studio installed, it failed to work, untill we added the line in Web.config.

Hitesh Gaur
July 17, 2013

# re: ASP.NET Routing not working on IIS 7.0

I am facing the same problem even though i have set the key to "runAllManagedModulesForAllRequests" to true. I have 73 routes to load but problem is that RegisterRoutes function is never being called by when application start. i have created two log files one from development environment and other from live environment

August 01, 2013

# re: ASP.NET Routing not working on IIS 7.0

We have test and deployed customer systems with Windows Server 2008 R2 Enterprise version 6.1 build 7601 SP1, IIS 7.5.* all of which worked fine with bundling.

We had one customer with Windows Server 2008 Standard version 6.0 build 6002 SP2, IIS 7.0.* which 404ed on all requests for bundled files.

We concluded that the problem was IIS7.0. The KB patch refused to install - said it wasn't needed, so we tried your fix and that works perfectly.

Rick Strahl
August 01, 2013

# re: ASP.NET Routing not working on IIS 7.0

@Phil - they might have rolled that into one of the .NET Framework updates since.

July 09, 2014

# re: ASP.NET Routing not working on IIS 7.0

This is a great thread going!

@txcraig and others let us to a working solution.

Adding the specific module needed worked for us. We had the "evil" runAllManagedModulesForAllRequests="true" attribute, but didn't want to use it because of the performance concerns (and should you just run all really?). Simply adding the correct module, and removing that evil attribute solved the problem.

We didn't install the patch for Windows 2008 SP2, IIS 7.0 we wanted to try to work around that.

<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />

Ashish Thakur
October 25, 2014

# re: ASP.NET Routing not working on IIS 7.0

Thanks Rick for posting such good articles,

I am able to perform GET and POST request through WebAPI on LocalHost development server via AJAX .

After deployment to IIS server on AWS I am not at all able to perform GET and POST through AJAX.( I have referred your articles related to WebAPI and ASP.Net passing multiple parameters and like others)

I have noticed following points after deployment to IIS Server.
1) when I typed URL for WebAPI I am able to get JSON data as expected from AWS.
2) AJAX returning error on POST and GET request
3) Fiddler returns JSON data as expected for GET

Is it related to ASP.Net Routing ?
Appreciate your time and guidance.

January 12, 2015

# re: ASP.NET Routing not working on IIS 7.0


Just want to add that a hotfix http://support.microsoft.com/kb/980368 did solve the problem, plus we removed everything from webserver section


September 15, 2015

# re: ASP.NET Routing not working on IIS 7.0

Thanks your post is very useful
I also refer very helpful and useful article about URL Routing in ASP.Net 3.5(IIS7)
Please visit this helpful article

Tomas Axelsson
July 18, 2016

# re: ASP.NET Routing not working on IIS 7.0

I had this problem as well... I used the standard web project in VS 2015.
Thanks a lot you saved me many hours by your great blog post!

December 15, 2017

# re: ASP.NET Routing not working on IIS 7.0

Today, you saved my friday evening. In other projects i had to add the modules part for other libraries, in this one i didn't need and i would have never guessed the link. Thanks !

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024