Asp.net mvc 2 将MVC 2应用程序从IIS 6迁移到IIS 7.5=重复的虚拟目录

Asp.net mvc 2 将MVC 2应用程序从IIS 6迁移到IIS 7.5=重复的虚拟目录,asp.net-mvc-2,iis-7.5,virtual-directory,Asp.net Mvc 2,Iis 7.5,Virtual Directory,我已经阅读了所有MVC标记的帖子,没有看到像我这样的问题,也没有发现任何能让我找到解决方案的东西,所以我希望有人能为我指明方向 我有一个MVC 2 web应用程序在Win 2003/IIS6的web表单应用程序下运行,我正在迁移到Win 2008/IIS7.5。我已经阅读了有关集成管道模式的内容,并对web配置进行了更改,以包含http处理程序的“System.webserver”元素。然后,加载Default.aspx页面将“domain/site1/site2/Default.aspx”的传

我已经阅读了所有MVC标记的帖子,没有看到像我这样的问题,也没有发现任何能让我找到解决方案的东西,所以我希望有人能为我指明方向

我有一个MVC 2 web应用程序在Win 2003/IIS6的web表单应用程序下运行,我正在迁移到Win 2008/IIS7.5。我已经阅读了有关集成管道模式的内容,并对web配置进行了更改,以包含http处理程序的“System.webserver”元素。然后,加载Default.aspx页面将“domain/site1/site2/Default.aspx”的传入请求重写为“domain/site1/site2/”,然后执行Homecontroller并加载索引视图。问题是Url.Content和Html.ActionLink解析为“/site1/site2/site2/”-注意重复的虚拟目录。URL没有因为重写而改变,所以我无法找出原因

下面是web.config中的webserver元素:

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

    <modules runAllManagedModulesForAllRequests="true">
        <remove name="ScriptModule"/>
        <remove name="UrlRoutingModule"/>
        <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </modules>

    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated"/>
        <remove name="ScriptHandlerFactory"/>
        <remove name="ScriptHandlerFactoryAppServices"/>
        <remove name="ScriptResource"/>
        <remove name="UrlRoutingHandler"/>
        <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <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>
AppPool设置为集成模式,允许32位应用程序为True,目标框架为2.0。
我也在AppPool上尝试了经典模式,在行为上没有差异


它在我的Win7开发盒上正确运行。有什么想法吗?

在搜索了SO和其他源代码之后,我找到了让我看MVC2源代码的地方。事实证明,在PathHelper类中,它会检查指示HTTP重写的HTTP头“HTTP_X_ORIGINAL_URL”。我在RewritePath语句之前的Default.aspx页面中添加了代码,以从ServerVariables集合中删除“HTTP_X_ORIGINAL_URL”,一切正常

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}")


    routes.MapRoute( _
        "Default", _
        "{controller}.aspx/{action}/{id}", _
        New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
    )
    routes.MapRoute( _
        "Root", _
        "", _
        New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
    )
End Sub