C# 在服务器2012和IIS 8上部署ASP.Net MVC时获得404
我已经尝试了我能在网上找到的每一个修复方法,但没有一个有效 我将asp.net 4.5和3.5角色添加到服务器 我将runAllManagedModulesForAllRequests添加到web.config中C# 在服务器2012和IIS 8上部署ASP.Net MVC时获得404,c#,asp.net-mvc,asp.net-mvc-4,iis,windows-server-2012,C#,Asp.net Mvc,Asp.net Mvc 4,Iis,Windows Server 2012,我已经尝试了我能在网上找到的每一个修复方法,但没有一个有效 我将asp.net 4.5和3.5角色添加到服务器 我将runAllManagedModulesForAllRequests添加到web.config中 <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http:/
<?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>
我从asp.net站点安装了MVC。我不确定还需要设置什么
这是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>
在不知道是哪个组件发布了404(可能是IIS或ASP.NET)的情况下,我的第一个想法是.NET没有向IIS注册,至少不是最新版本。如果IIS抛出404,它将如下所示: 如果ASP.NET工作正常,404将如下所示: 如果您是从IIS获取404,请尝试重新运行aspnet_regiis.exe-i。在我的windows 8系统上,路径位于此处:“C:\windows\Microsoft.NET\Framework\v4.0.30319\aspnet\u regiis.exe”
此处的更多详细信息:听起来很基本,如果
运行所有ManagedModulesForallRequests
和IIS目录权限不能解决您的问题…请尝试完全擦除并重新部署站点。我必须为IIS安装“IIS客户端证书映射身份验证”角色服务,以清除此错误。我的网站配置了客户端证书身份验证。默认情况下,在Windows 8上,IIS不会安装ASP.NET,因此请转到“打开/关闭Windows功能”并在IIS检查->万维网服务->应用程序开发功能->ASP.NET 4.5下
这对我有用 我的问题和你描述的一样。我在不同的资源上搜索了很长一段时间,并尽了我所能。但解决办法很简单 我打开Global.asax.cs,将代码放在try\u catch块中的方法“Application\u Start(object sender,EventArgs e)”中。然后,我将我的项目附加到w3wp.exe,并将断点放在Global.asax.cs中。我重新构建了webApp,并尝试从浏览器调用我的站点。当我到达断点时,我按F5键并在Catch块中得到错误消息 我的问题是缺少一些DLL,尽管该项目在构建时没有任何警告或错误。此外,我还引用了NPGSQL和我的其他一些dll,它们引用了NPGSQL。WebApp中NPGSQL的版本与我的另一个dll中的版本不同。所以这也造成了问题
请尝试调试web应用程序的启动,希望它能帮助您。检查IIS中的站点绑定。确保未绑定到可能正在使用的系统端口或其他端口,从而导致冲突。通常,编号较高的端口不太可能被使用 端口分配列表:
我得到了第二个错误。我运行了你建议的更新命令,但我仍然得到了404。同一个站点在另一台运行2008r2的服务器上运行正常,因此我确信这是IIS的设置问题。您能否添加404消息的屏幕截图以及IIS安装设置的外观?例如,我的设置如下所示: