将 ASP.NET MVC 3 项目转换为 MVC 4

问题描述:

我应该采取什么步骤将现有的 ASP.NET MVC 3 项目安全地升级到最新的 ASP.NET MVC 4 开发者预览版?

What steps should I take to safely upgrade an existing ASP.NET MVC 3 project to the latest ASP.NET MVC 4 Developer Preview?

主要变化是将相关参考升级到最新版本(4.0/2.0).您需要更新您的网络配置文件以升级以下命名空间的版本

The major change is to upgrade the relevant references to the latest version (4.0 /2.0). You need to update your web config files to upgrade the version of the following namespaces

  • System.Web.Mvc(更改为 4.0.0.0)
  • System.Web.Webpages(更改为 2.0.0.0)
  • System.Web.Helpers(更改为 2.0.0.0)
  • System.Web.WebPages.Razor(更改为 2.0.0.0)

您还需要更新根级 Web 配置文件以包含这些 appsettings 条目

Also you need to update the root level web config file to have these appsettings entries

<appSettings>
  <add key="webpages:Version" value="2.0.0.0" />
  <add key="PreserveLoginUrl" value="true" />
</appSettings>

然后需要更新项目中引用的DLL.删除现有的 MVC3 dll 引用并添加 MVC4(使用 nuget 包管理器执行此操作)

Then you need to update the DLLs referenced in the project. Remove the existing MVC3 dll reference and add MVC4 (use nuget package manager to do this)

这个link 处理转换的所有方面.根据需要参考.

This link handles all aspects of the conversion. Refer it as needed.