Getting 404.0 error for ASP.NET MVC 3 app on IIS 7.0 / Windows Server 2008

前端 未结 6 2151
不思量自难忘°
不思量自难忘° 2020-12-24 13:18

I am attempting to deploy an ASP.NET MVC 3 application to a Windows 2008 x64 server (running IIS 7.0 obviously), and IIS does not want to seem to serve up the content proper

6条回答
  •  被撕碎了的回忆
    2020-12-24 13:51

    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:

      
        
        
      
        
        
      
        
          
        
      
        
          
          
            
          
      
          
          
        
      
    • 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(
                "{*message}",
              //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()
             );
      
          System.Web.Routing.RouteTable.Routes.Add(echoRoute);
      }
      
    • PassthroughRouteHandler.cs - this achieved an automatic conversion from http://andrew.arace.info/stackoverflow to http://andrew.arace.info/#stackoverflow 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;
          }
      }
      

提交回复
热议问题