2013-07-05 24 views
4

我在IIS中設置了URL路由。當我將runAllManagedModulesForAllRequests設置爲true時,URL路由將起作用。ASP.Net URL路由只適用於`runAllManagedModulesForAllRequests`爲真

用下面的web.config文件(和runAllManagedModuesForAllRequests設置爲false),我收到了404:

<system.web> 
    <compilation defaultLanguage="c#" debug="true" targetFramework="4.5"> 
     <assemblies> 
     <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </assemblies> 
    </compilation> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
     <remove name="UrlRoutingHandler" /> 
     <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> 
    <modules> 
     <remove name="UrlRoutingModule" /> 
     <add name="UrlRoutingModule" 
      type="System.Web.Routing.UrlRoutingModule, 
       System.Web.Routing, 
       Version=3.5.0.0, 
       Culture=neutral, 
       PublicKeyToken=31BF3856AD364E35"/> 
    </modules> 
    </system.webServer> 

如何設置URL路由僅針對特定的請求?

我已經在IIS 7.5和IIS 8中測試了這個配置。這是在一個web表單應用程序中。所有網址都顯示了404的行爲。

+0

IIS7? IIS7.5? IIS8?哪些網址?擴展名的?或者這是一個ASP.NET MVC應用程序,在這種情況下你需要註冊你的路線。需要更多信息。 – Ted

+0

向問題主體添加了幾個句子來回答您的問題。 – Darbio

+0

擴展名和擴展名網址?即.aspx和no .aspx? – Ted

回答

0

「runAllManagedModulesForAllRequests」爲true,表示當您處於集成模式時,asp.net處理程序將觸發所有擴展(包括無擴展),如果您沒有aspx並且它設置爲假你的模塊不能處理它。

您無法爲您要實現的內容設置擴展的子集,但您可以在模塊中自行篩選它以僅處理某些擴展。