IIS7的ASP MVC路由问题 [英] ASP MVC routing problem with IIS7

查看:59
本文介绍了IIS7的ASP MVC路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在IIS7服务器上部署MVC应用程序时发现了问题:任何路由导航都会出现404错误.我在网上发现,可以通过将应用程序池托管管道模式设置为集成来解决问题,但是现在我们有一个例外:

We discovered problem when deploying MVC application on IIS7 server: any route navigation gives 404 error. I've found on web that problem can be solved by setting application pool managed pipeline mode to integrated, but now we have exception:

Request is not available in this context

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Request is not available in this context

Source Error: 


Line 19: 
Line 20:         public override void SetActiveUser(Guid userOid) {
Line 21:             FormsAuthentication.SignOut();
Line 22:             HttpContext.Current.Items[Key] = userOid.ToString();
Line 23:             FormsAuthentication.RedirectFromLoginPage(userOid.ToString(), true); 

有人有什么主意吗?

推荐答案

问题可能出在web.config文件中.从IIS7开始,现在有两个地方可以配置处理程序和模块.在经典模式下运行时,就像在IIS 6上运行(尽管在IIS7下).

The problem is probably in the web.config file. Since IIS7 there is now two places to configure handlers and modules. When you run in classic mode, is like running on IIS 6 (though under IIS7).

这是配置文件:

<system.web>
[...]
    <httpHandlers>
            [...]
        </httpHandlers>
        <httpModules>
            [...]
            <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

        </httpModules>
    </system.web>

应该只有IIS 6配置.

there should be only IIS 6 configurations.

IIS 7配置应放在以下位置:

IIS 7 config should be placed under:

    <system.webServer>
[...]
            <modules runAllManagedModulesForAllRequests="true" >
                <remove name="UrlRoutingModule"/>
                <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            </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>

这篇关于IIS7的ASP MVC路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆