从MVC 4(4.5)升级到MVC 5(4.5.1) [英] upgrade from mvc 4 (4.5) to mvc 5 (4.5.1)

查看:100
本文介绍了从MVC 4(4.5)升级到MVC 5(4.5.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要升级在VS 2012(.NET框架4.5)开发MVC 5(.NET框架4.5.1)。

I need to upgrade a MVC 4 project developed in VS 2012 (.NET Framework 4.5) to MVC 5 (.NET Framework 4.5.1).

第一个场景

我已经按照有关asp.net的教程(<一个href=\"http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2\" rel=\"nofollow\">http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 )。该项目成功建立,但是当我运行它,我得到了一个错误: 403.14 - Web服务器配置为不列出此目录的内容目录浏览被禁用(正确的)。这应该映射到/ home /指数?我已经证实,DNS /绑定是通过将​​一个静态的html文件中的现场工作,这工作得很好。

I've followed the the tutorial on asp.net ( http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 ).The project builds successfully but when I run it I got an error: 403.14 - The Web server is configured to not list the contents of this directory. The directory browsing is disabled (correct). This should map to /home/index? I have confirmed that the DNS/binding is working by putting a static html file in the site and this works fine.

第二个场景

我创建了VS2013空项目,并做了复制/包含的所有文件。它成功地构建和运行在本地机器罚款,但是当我把它发布到服务器我得到了一个错误:403 - 禁止:拒绝访问。我还证实,DNS /绑定是通过将​​一个静态的html文件中的现场工作。

I created an empty project in VS2013 and did copy/include all files. It builds successfully and runs on local machine fine but when I publish it to the server I got an error: 403 - Forbidden: Access is denied. I have also confirmed that the DNS/binding is working by putting a static html file in the site.

我也试过(MVC 4)发布应用程序的旧版本的服务器,它工作正常。

I have also tried to publish the app’s ‘old version’ (MVC 4) to the server and it works fine.

IDE:VS 2013
.NET框架:4.5.1
本地操作系统:Win 7的SP1
服务器:赢Server 2012的标准

IDE: VS 2013 .NET Framework: 4.5.1 Local OS: Win 7 SP1 Server: Win Server 2012 Standard

推荐答案

所有你需要更新首先在现有的NuGet packages.Because有些是用新的不兼容。这样做之前,请保留一个备份您现有的
应用

First of all you need to update all the existing nuget packages.Because some are incompatible with the new one. Before doing it please keep a back up of your existing application

第1步:框架更改为4.5.1。您需要通过右键单击项目的目标框架更改为ATLEAST 4.5。

Step 1 : Change the framework to 4.5.1. You need to change the target framework to atleast 4.5 by right clicking the projects.


第二步:
然后,你需要在解决方案更新包level.Because它会在所有的项目更新包的能力
在此solution.For右键单击该解决方案,然后选择管理的NuGet包的解决方案选项。

Step2 : Then you need to update the packages at the solution level.Because it will get the ability to update the packages in all the projects in the solution.For this right click the solution and select 'Manage Nuget Packages for solution' option.

第三步:从安装软件包选中 Microsoft.AspNet.Web.Helpers.Mvc 包和卸载it.Because它是在新版本中,MVC5重命名。卸载点击管理按钮,取消了webproject并单击确定。

Step3 : From the install packages select the Microsoft.AspNet.Web.Helpers.Mvc packages and Uninstall it.Because it is renamed in the new version ,MVC5.For uninstalling click the Manage button and uncheck the webproject and click ok.

第四步:,然后去更新包和更新一些软件包,如 Microsoft.ASP.NET MVC,实体框架和的WebAPI版本2 。我的策略是更新到顶层packages.When更新这个会更新一些粥packages.Now可以看到packages.config文件,如MVC4到MVC5,剃刀版本更改从2到3,距离也是网页版的变化2至3个

Step4 : Then go to the update packages and update some packages such as Microsoft.ASP.NET MVC,Entity Framework and WebApi version 2. My strategy is to updating to the top level packages.When updating this it will update some ather packages.Now you can see the changes in packages.config file such as MVC4 to MVC5,Razor version change from 2 to 3 and also Webpage version from 2 to 3.

第五步::改变我们的配置文件的版本,以及像下面

Step5 : Change the version in our config file as well like below.

这些都是顶级配置文件的修改

these are the changes in the top level config file

第六步:,然后还需要完成在视图配置文件中的一些变化,如配置文件的所有部分更新剃刀版本号为3和MVC版本5

Step 6 : Then also you need to done some changes in views config file such as updating the razor version to 3 and MVC version to 5 in all the parts of the config file

第7步:安装多一个包。转到管理的NuGet经理选项>>在线选择表>>搜索 Microsoft.Aspnet.Webhelpers 并安装软件包。

Step 7 : install one more package. Go to manage nuget manager option >> select online table >> search for Microsoft.Aspnet.Webhelpers and install the package.

*的第8步:* 的卸载webproject并右键单击并选择编辑PROJ选项和删除GUID开始,E3,因为我们不需要此GUID在我们的新项目

*Step 8 : * Unload the webproject and right click and select edit proj option and the remove the guid starting with E3 because we no need this guid in our new project.

保存并重新加载项目并生成并运行应用程序
希望这有助于信息您

Save and reload the project again and build and run the application Hope this informations helps you

这篇关于从MVC 4(4.5)升级到MVC 5(4.5.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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