MVC框架执行解析Url的路由与传统WebForm页面的执行

MVC框架中,需要通过配置文件web.config注册HTTP模块,在HttpModules节中注册HttpRoutingModule类,用来解析URL的路由。

UrlRoutingModule模块注册的实现代码:

<httpModules>
    <add name="UrlRoutingModule" type="System.Web.RoutingUrlRoutingModule,
		 System.Web.Routing,Version=4.7.2, Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

MVC网站页面中存在WebForm页面时,若将aspx页面当做普通WebForm页面来执行,MVC框架中默认设置项:

RouteTable.Routes.RouteExistingFiles = false;

当网站出现以下错误:

An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

有两种解决方法:

1.将线程池中托管管道模式改为:经典

2.web配置文件中增加项:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
</system.webServer>

 

posted @ 2022-03-20 10:26  xmllxm  阅读(61)  评论(0)    收藏  举报