Search code examples
asp.netiisroutesurl-routingasp.net-routing

HTTP Error 404.0 - Not Found, Error Code 0x80070002; routing extensionless url in IIS


I read many articles about it and tested, but my problem has still not been resolved

HTTP Error 404.0 - Not Found

I used UrlRoutingModule to have friendly URL

In global.asax.cs:

routes.MapPageRoute("", "HOME", "~/Default.aspx");

In web.config:

<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>`

In IIS, Application Pool is in Classic mode

The following solutions are tested:

  • add to web.config <modules runAllManagedModulesForAllRequests="true">
  • add to web.config <validation validateIntegratedModeConfiguration="false" />
  • add to web.config <remove name="UrlRoutingModule"/>
  • enable IIS service "HTTP Redirection"
  • enable IIS service "HTTP Error"
  • enable IIS service "HTTP Logging"
  • enable IIS service "Static Content Compression"
  • enable IIS service "Dynamic Content Compression"
  • enable IIS service "Request Monitor"
  • reinstall IIS !

Note 1:

Routing worked on extensioned URL, for example when i changed routing rule in global.asax.cs to

routes.MapPageRoute("", "HOME.aspx", "~/Default.aspx");

the URL "mysite/HOME.aspx" worked

Note 2:

This case, with exact this configuration is working on 2 other servers!

Note 3:

On this server, routing worked by set application pool to integrated mode + <validation validateIntegratedModeConfiguration="false" />


Solution

  • This is a bit of a shot in the dark because you mention that this configuration is working on some servers but not others.

    As mentioned in this post, there is a bug in IIS that Microsoft has released a hotfix for that you might want to check the servers to see if they have been patched consistently for KB980368.

    And as the article points out the problem only applies to .NET 4.0. Since you are (apparently) using .NET 3.5, you might want to double-check your application pool configurations to ensure they are all consistently set to .NET 2.0 and your web.config settings to ensure you are targeting .NET 3.5.

    Do note that Microsoft officially ended support for .NET 4.0 on January 12, 2016, but support for .NET 3.5 SP1 will will continue until support ends for the OS you are hosting it on.