Asp.net

asp.net 4 路由在 iis 7 中不起作用

  • March 27, 2019

我在我們的一款新產品中使用 asp.net 4 路由,它在開發環境(Visual Studio 網路伺服器)中執行良好。但是當我將它移到遠端 iis 以進行測試時,它不起作用。我得到的只是 404 錯誤頁面。我嘗試將以下內容添加到 web.config 並仍然收到錯誤。

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">    
    <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>

任何想法如何解決這個問題?

我得到了解決方案…在您的 web.config 中添加以下程式碼 ..並且不要忘記在您的模組中添加 runAllManagedModulesForAllRequests=“true” ..

  <system.webServer> 
       <modules runAllManagedModulesForAllRequests="true"> 
         <remove name="UrlRoutingModule"/> 
         <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
       </modules> 
       <handlers> 
         <add 
           name="UrlRoutingHandler" 
           preCondition="integratedMode" 
           verb="*" path="UrlRouting.axd" 
           type="System.Web.HttpForbiddenHandler, System.Web,  
             Version=2.0.0.0, Culture=neutral,  
             PublicKeyToken=b03f5f7f11d50a3a"/> 
       </handlers> 
     </system.webServer>

引用自:https://stackoverflow.com/questions/4428278