Routing HTTP Error 404.0 0x80070002


I have created routing rules in my ASP.NET application and on my Dev machine at IIS7 everything works fine. When I deploy solution to prod server which has also IIS7 I get error 404 (page not found) while accessing URL. Maybe someone could point where is the problem?

Actual error

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error InformationModule IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL Physical Path C:\www\pathtoproject\pdf-button Logon Method Anonymous Logon User Anonymous

My Actual Code

     <add key="RoutePages" value="all,-forum/"/>


    public static class UrlRewrite
            public static void Init(string routePages)

                _routePages = routePages.ToLower().Split(new[] { ',' });


            static void RegisterRoute(RouteCollection routes)

                foreach (string routePages in _routePages)
                    if (routePages == "all")
                        routes.MapPageRoute(routePages, "{filename}", "~/{filename}.aspx");
                        if (routePages.StartsWith("-"))
                            routes.Ignore(routePages.Replace("-", ""));
                            var routePagesNoExt = routePages.Replace(".aspx", "");
                            routes.MapPageRoute(routePagesNoExt, routePagesNoExt, string.Format("~/{0}.aspx", routePagesNoExt));

asked on Stack Overflow Apr 15, 2011 by Tomas • edited Apr 15, 2011 by Tomas

6 Answers


Just found that lines below must be added to web.config file, now everything works fine on production server too.

  <modules runAllManagedModulesForAllRequests="true" >
   <remove name="UrlRoutingModule"/>    
answered on Stack Overflow Apr 15, 2011 by Tomas • edited Sep 25, 2018 by Rajmond Burgaj

The solution suggested

  <modules runAllManagedModulesForAllRequests="true" >
    <remove name="UrlRoutingModule"/>    

works, but can degrade performance and can even cause errors, because now all registered HTTP modules run on every request, not just managed requests (e.g. .aspx). This means modules will run on every .jpg .gif .css .html .pdf etc.

A more sensible solution is to include this in your web.config:

    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />

Credit for his goes to Colin Farr. Check-out his post about this topic at

answered on Stack Overflow Oct 22, 2015 by Robert Bethge

My solution, after trying EVERYTHING:

Bad deployment, an old PrecompiledApp.config was hanging around my deploy location, and making everything not work.

My final settings that worked:

  • IIS 7.5, Win2k8r2 x64,
  • Integrated mode application pool
  • Nothing changes in the web.config - this means no special handlers for routing. Here's my snapshot of the sections a lot of other posts reference. I'm using FluorineFX, so I do have that handler added, but I did not need any others:

      <compilation debug="true" targetFramework="4.0" />
      <authentication mode="None"/>
      <pages validateRequest="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
      <httpRuntime requestPathInvalidCharacters=""/>
        <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/>
        <!-- Modules for IIS 7.0 Integrated mode -->
          <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx" />
        <!-- Disable detection of IIS 6.0 / Classic mode ASP.NET configuration -->
        <validation validateIntegratedModeConfiguration="false" />
  • Global.ashx: (only method of any note)

    void Application_Start(object sender, EventArgs e) {
        // Register routes...
        System.Web.Routing.Route echoRoute = new System.Web.Routing.Route(
            //the default value for the message
              new System.Web.Routing.RouteValueDictionary() { { "message", "" } },
            //any regular expression restrictions (i.e. @"[^\d].{4,}" means "does not start with number, at least 4 chars
              new System.Web.Routing.RouteValueDictionary() { { "message", @"[^\d].{4,}" } },
              new TestRoute.Handlers.PassthroughRouteHandler()
  • PassthroughRouteHandler.cs - this achieved an automatic conversion from to which would then be handled by the default.aspx:

    public class PassthroughRouteHandler : IRouteHandler {
        public IHttpHandler GetHttpHandler(RequestContext requestContext) {
            HttpContext.Current.Items["IncomingMessage"] = requestContext.RouteData.Values["message"];
            requestContext.HttpContext.Response.Redirect("#" + HttpContext.Current.Items["IncomingMessage"], true);
            return null;
answered on Stack Overflow Mar 17, 2012 by Andrew Arace

The problem for me was a new server that System.Web.Routing was of version 3.5 while web.config requested version The resolution was

%WINDIR%\Framework\v4.0.30319\aspnet_regiis -i

%WINDIR%\Framework64\v4.0.30319\aspnet_regiis -i

answered on Stack Overflow Dec 16, 2015 by Yaron Habot

Uncheck this in Windows Explorer.

"Hide file type extensions for known types"

answered on Stack Overflow Apr 10, 2015 by MacGyver • edited Apr 13, 2015 by MacGyver

Having this in Global.asax.cs solved it for me.

protected void Application_Start()
answered on Stack Overflow Mar 2, 2017 by wolfQueen • edited Sep 24, 2018 by Rajmond Burgaj

User contributions licensed under CC BY-SA 3.0