ASP.Net URL routing only works if `runAllManagedModulesForAllRequests` is true

I have configured URL routing in IIS. When runAllManagedModulesForAllRequests set to true, URL routing works.

Using the following web.config (and runAllManagedModuesForAllRequests set to false) I get 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> 

How to configure URL routing only for specific requests?

I tested this configuration in IIS 7.5 and IIS 8. This is a web form application. All URLs show 404 behavior.

+4
source share
1 answer

"runAllManagedModulesForAllRequests" is true, means that the asp.net handler (of course, when you are in integrated mode) will run for all extensions (including an extension without an extension) if you do not have aspx and it is set to false your module cannot process it.

You cannot configure a subset of extensions for what you are trying to achieve, but you can filter it yourself in the module to handle specific extensions.

0
source

Source: https://habr.com/ru/post/1489844/


All Articles