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

前端 未结 6 2129
不思量自难忘°
不思量自难忘° 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:36

    The issue ended up being that my code was completely relying on the auto-start functionality that is available only in IIS 7.5. I was able to discover the issue with the help of the Failed Request Tracing feature in IIS, and I have now modified my global.asax.cs file so that the application will be properly initialized, regardless of how/when it is loaded.

    0 讨论(0)
  • 2020-12-24 13:44

    If you are running your web application on IIS 7.5 or above, please ensure that the role services for IIS are enabled properly. The role services of interest are : ASP.NET, Basic Authentication, HTTP Redirection, ISAPI filters, etc.

    You could go to the role services via Add or Remove programs - Turn Windows features on or off. Hope this helps.

    Regards, Kiran Banda

    0 讨论(0)
  • 2020-12-24 13:51

    You actually just reminded me that I needed to fix this issue in an enviroment here. If your situation is the same as mine then it's a simple fix.

    Just add the following to your web config:

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

    Edit: To provide further explanation on the issue at hand. In my case what was happening was when I added custom route mappings IIS was seeing the requests as Folder/Static File requests and thus was skipping over the ASP.NET worker process. This behaves differently under development environment generally because it is being run under the development web server which will also pass all requests through the .net process.

    This Web Config entry tells IIS that you have modules that should be run on every web request even if IIS determines it to be a static file or a folder.

    0 讨论(0)
  • 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:

      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <authentication mode="None"/>
      
        <pages validateRequest="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
        <httpRuntime requestPathInvalidCharacters=""/>
      
        <httpModules>
          <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/>
        </httpModules>
      </system.web>
        <system.webServer>
          <!-- Modules for IIS 7.0 Integrated mode -->
          <modules>
            <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx" />
          </modules>
      
          <!-- Disable detection of IIS 6.0 / Classic mode ASP.NET configuration -->
          <validation validateIntegratedModeConfiguration="false" />
        </system.webServer>
      
    • 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;
          }
      }
      
    0 讨论(0)
  • 2020-12-24 13:56

    I had the same problem. Mine ended up being a failed assembly upon the app starting. I enabled the Fusion Log Viewer to see which assemblies were failing and figured it out. I would have never discovered this since it seemed like an MVC routing issue, but I figured I would post this incase anyone else wasted hours on this problem as well!

    0 讨论(0)
  • 2020-12-24 13:57

    Please make sure that you are running under IIS 7.0 Integrated mode. If you need to run it under IIS 7.0 Classic mode, you need to perform several actions to make the routes work. Please refer the following blog posts;

    http://www.tugberkugurlu.com/archive/running-asp-net-mvc-under-iis-6-0-and-iis-7-0-classic-mode---solution-to-routing-problem

    http://www.tugberkugurlu.com/archive/deployment-of-asp-net-mvc-3-rc-2-application-on-a-shared-hosting-environment-without-begging-the-hosting-company

    0 讨论(0)
提交回复
热议问题