更新时间:2022-01-24 10:46:13
使用 IIS 7.5 启用默认的 ASP.Net 4.0 路由:
To enable default ASP.Net 4.0 routing with IIS 7.5:
web.config
web.config
with the code below
<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>
3.在 global.asax
文件中创建路由
3. Create Routes in your global.asax
file
注意:您必须将应用程序池设置为 Asp.net 4.0 应用程序池,因为路由不适用于 Asp.net 4.0 经典应用程序池.
Note: You have to set Application Pool to Asp.net 4.0 application pool , as routing is not working with Asp.net 4.0 Classic Application pool.
希望这会有所帮助.