简体   繁体   中英

Getting 404 when deploying ASP.Net MVC on Server 2012 and IIS 8

I've Tried every fix I can find online and none of them have worked.

I added the asp.net 4.5 and 3.5 role to the server.

I added the runAllManagedModulesForAllRequests into the web.config

I installed MVC from the asp.net site. I'm not sure what else needs to be set.

Here's the web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Redacted" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="Off" />
    <machineKey validationKey="96820F5717A865002768570C77EC72BBBC16CD2BDBC3D6BD494F4F4734F903FEBDA99E0A694ADB5B2A6D9347FB60BE00F1BF618062DA36C8A378B0B274B80390" decryptionKey="71AA018320CA48F100A58E38285B3AEE7C2E21001C1ASDD1" validation="SHA1" />
    <authentication mode="None" />
    <compilation targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="FormsAuthenticationModule" />
    </modules>
        <defaultDocument>
            <files>
                <clear />
                <add value="default.aspx" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
            </files>
        </defaultDocument>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

Without knowing what component is issuing the 404 (could be IIS or ASP.NET), my first thought is that .net isn't registered with IIS, at least not the latest version. If IIS is throwing the 404 it will look something like this: http://imgur.com/7crGkNg

If ASP.NET is working properly, the 404 will look something like this: http://imgur.com/MIVYSNv

If you are getting the 404 from IIS, try re-running aspnet_regiis.exe -i. On my windows 8 system the path is located here: "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\aspnet_regiis.exe"

More details here: http://msdn.microsoft.com/en-us/library/k6h9cz8h(v=vs.100).aspx

By Default on Windows 8, the IIS will not install ASP.NET so go to "Turn Windows Features On/Off" and under IIS check-> World Wide Web Services-> Application Development Features-> ASP.NET 4.5

This worked for me.

听起来很基本,如果runAllManagedModulesForAllRequests和IIS目录权限不能解决您的问题...请尝试完全擦除并重新部署该站点。

I had to install the "IIS Client Certificate Mapping Authentication" role service for IIS in order to clear out this error. My site is configured with client certificate authentication.

I had the same problem as you describe. I searched for a long time on different resources and tried everything I could. But the solution was so simple...

I opened Global.asax.cs, put the code in method "Application_Start(object sender, EventArgs e)" in try_catch block. Then I attached my project to w3wp.exe and put a breakpoint at in Global.asax.cs. I rebuilded the webApp and tried to call my site from the browser. When I hit the breakpoint I pressed F5 and got the error message in my Catch block.

My problem was in some missing dlls, though the project would built without any warnings or errors. Also, I had a reference to NPGSQL and to some my other dll that has a reference to NPGSQL. And the version of NPGSQL in WebApp was different from the version in my other dll. So that caused the problem too.

Just try to debug the start of your web application, hope it will help you.

Check site bindings in IIS. Make sure you are not binding to a system port or other port that may be in use, causing a collision. Generally, higher-numbered ports are less likely to be in use.

List of port # assignments:

https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM