![](/img/trans.png)
[英]Deploying a ASP.NET MVC 5 Application in Windows Server 2012
[英]Getting 404 when deploying ASP.Net MVC on Server 2012 and IIS 8
我已經嘗試了所有可以在網上找到的修復程序,但沒有一個起作用。
我向服務器添加了asp.net 4.5和3.5角色。
我將runAllManagedModulesForAllRequests添加到web.config中
我從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,它將看起來像這樣: http : //imgur.com/7crGkNg
如果ASP.NET正常運行,則404看起來會像這樣: http : //imgur.com/MIVYSNv
如果要從IIS獲取404,請嘗試重新運行aspnet_regiis.exe -i。 在我的Windows 8系統上,路徑位於此處:“ C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ aspnet_regiis.exe”
此處有更多詳細信息: http : //msdn.microsoft.com/zh-cn/library/k6h9cz8h(v=vs.100).aspx
在Windows 8上,默認情況下,IIS不會安裝ASP.NET,因此請轉到“打開/關閉Windows功能”,然后在IIS下,選中“萬維網服務”->“應用程序開發功能”->“ ASP.NET 4.5”
這對我有用。
聽起來很基本,如果runAllManagedModulesForAllRequests
和IIS目錄權限不能解決您的問題...請嘗試完全擦除並重新部署該站點。
我必須為IIS安裝“ IIS客戶端證書映射身份驗證”角色服務,以清除此錯誤。 我的站點配置了客戶端證書身份驗證。
我遇到了與您描述的問題相同的問題。 我在不同的資源上搜索了很長時間,並嘗試了所有可能的方法。 但是解決方案是如此簡單...
我打開Global.asax.cs,將代碼放在try_catch塊中的“ Application_Start(object sender,EventArgs e)”方法中。 然后,我將項目附加到w3wp.exe,並在Global.asax.cs中放置一個斷點。 我重建了webApp,並嘗試通過瀏覽器調用我的網站。 當我達到斷點時,我按了F5鍵,並在Catch塊中收到了錯誤消息。
我的問題是缺少一些dll,盡管該項目在構建時沒有任何警告或錯誤。 此外,我還引用了NPGSQL和其他一些引用了NPGSQL的dll。 WebApp中NPGSQL的版本與我其他dll中的版本不同。 因此,這也引起了問題。
只需嘗試調試Web應用程序的啟動,希望它將對您有所幫助。
檢查IIS中的站點綁定。 確保您未綁定到可能正在使用的系統端口或其他端口,從而導致沖突。 通常,編號較高的端口不太可能被使用。
端口號分配列表:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.