asp.net 4路由无法在iis 7中运行

Ane*_*eef 16 asp.net routing iis-7

我在我们的一个新产品中使用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>
Run Code Online (Sandbox Code Playgroud)

任何想法如何排序这个问题?

小智 37

我得到了解决方案...在你的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>
Run Code Online (Sandbox Code Playgroud)

  • `<modules runAllManagedModulesForAllRequests ="true">`对我有用.我花了3个小时试图解决这个问题. (5认同)
  • 我不确定所有代码是否必要,我的webforms ASP.Net 4.0应用程序只需要runAllManagedModulesForAllRequests ="true"添加到<modules>以使其工作 - 不需要其他更改. (3认同)
  • @Nick - 在Windows 2008服务器上的IIS7上需要这个,但在Windows 7(本地开发)上的IIS7上不需要它!有趣吗? (2认同)