我在我们的一个新产品中使用asp.net 4路由,它在开发环境(Visual studio webserver)中工作正常。但是当我将它移动到远程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>
注意:您必须将应用程序池设置为Asp.net 4.0应用程序池,因为路由不适用于Asp.net 4.0 Classic Application池。