在MVC項目或者webAPI項目發佈以後有時會發生404錯誤。針對這種錯誤的解決辦法:html
解決辦法1(不推薦):
在webconfig中 <system.webServer> 節點下 添加 <Modules runAllManagedModulesForAllRequests="true" >的節點web
<system.webServer> <modules runAllManagedModulesForAllRequests="true"> </modules> </system.webServer>
一、這些問題的形式是使全部註冊的HTTP模塊在每一個請求上運行,而不單單是託管請求。好比圖片、CSS等。服務器
二、可能導出全局錯誤,而且浪費服務器資源spa
解決辦法2(比較好):
htm
<system.webServer> <modules> <remove name="UrlRoutingModule-4.0" /> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> </modules> </system.webServer>
解決辦法3(更好):blog
<system.webServer> <handlers> <add name="htmlHandler" verb="GET,HEAD" path="*.html" type="System.Web.StaticFileHandler"/> </handlers> </system.webServer>