简体   繁体   English

MVC 2 / ASP.NET 4.0 App无法正常工作

[英]MVC 2/ASP.NET 4.0 App not working

I have picked up a project that is currently broken and I'm trying to fix it. 我选择了一个当前已中断的项目,正在尝试对其进行修复。

The application was last working correctly as a .NET 3.5 Web Forms application with some features implemented in MVC 2.0. 该应用程序最后一次正常运行为.NET 3.5 Web窗体应用程序,具有在MVC 2.0中实现的某些功能。

The application has become broken when it was upgraded to .NET 4.0 and is running on IIS 7. The Web Forms features work fine, but the MVC 2.0 parts no longer work. 升级到.NET 4.0并在IIS 7上运行时,该应用程序已损坏。Web窗体功能可以正常使用,但MVC 2.0部分不再起作用。 Browsing to an MVC URL fails with a 404 error. 浏览到MVC URL失败,并显示404错误。 It seems as if MVC does not kick in when the URL is browsed. 浏览URL时似乎没有启动MVC。

I've put extracts from the web.config below. 我从下面的web.config中提取了内容。

<compilation defaultLanguage="c#" debug="true">
  <assemblies>
    <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>      
  </assemblies>
</compilation>

<system.webServer>
    <modules>
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
    </handlers>
</system.webServer>

It works on the development PC (Windows 7). 它可以在开发PC(Windows 7)上运行。 Why is MVC not working when deployed to IIS 7 (Win 2k8)? 为什么将MVC部署到IIS 7(Win 2k8)时不起作用?

The modules element requires the runAllManagedModulesForAllRequests to be set as described in this answer . modules元素要求按照此答案中所述设置runAllManagedModulesForAllRequests

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
    <handlers>
    </handlers>
</system.webServer>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM