Getting 404 error on MVC web-site

前端 未结 14 1084
暗喜
暗喜 2020-12-06 05:49

I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site deployed to it. The website was built in Visual Studio 2008, targeting .NET 3.5, and IIS 5.1

相关标签:
14条回答
  • 2020-12-06 06:19

    Typically I encounter this issue when there is a Routing problem. I compare a working vs non-working to resolve it.


    Today however I accidentially created a Virtual Directory in IIS.

    It has to be an Application, right click on the Virtual Directory (with a folder icon) -> Convert to Application:

    0 讨论(0)
  • 2020-12-06 06:20

    If none of the other solutions here solved your issue, check that you have the

    Global.asax

    file in your website. This solved the issue for me.

    0 讨论(0)
  • 2020-12-06 06:22

    We finally nailed this issue by exporting the IIS configuration of a working server, and comparing it to ours.

    It was a really obscure setting which had been changed from the default.

    IIS ROOT → request Filtering → Filename Extensions Tab → Edit Feature Settings → Allow unlisted file name extensions

    This should be ticked.

    This can be set at the IIS level, or the site-level.

    Screenshot of IIS showing location of Request Filtering option

    0 讨论(0)
  • 2020-12-06 06:24

    In addition to checking if you're running in integrated pipeline mode, make sure your application pool is set to use .NET! I recently ran into this problem, and when I went in to check the app pool settings, I found that somehow it had been set to "No Managed Code." Whoops!

    enter image description here

    0 讨论(0)
  • 2020-12-06 06:25

    This is quite often caused by the following missing from the web.config:

    <system.webServer>
       <modules runAllManagedModulesForAllRequests="true"/> 
    
    0 讨论(0)
  • 2020-12-06 06:25

    Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.

    <system.webServer> <!-- Rather do NOT use this -->
      <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
    

    Instead add the MVC routing module

    <system.webServer>
      <modules>
        <remove name="UrlRoutingModule-4.0" />
        <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
      </modules>
    </system.webServer>
    
    0 讨论(0)
提交回复
热议问题