【MVC4升级到MVC5】ASP.Net MVC 4项目升级MVC 5…
2018-06-22 06:02:28来源:未知 阅读 ()
1、备份你的项目
2、从Web API升级到Web API 2,修改global.asax,将
1
|
WebApiConfig.Register(GlobalConfiguration.Configuration); |
修改为
1
|
GlobalConfiguration.Configure(WebApiConfig.Register); |
3、通过Nuget,更新下面的包
包名 |
旧版本 |
新版本 |
Microsoft.AspNet.Razor |
2.0.x.x |
3.0.0 |
Microsoft.AspNet.WebPages |
2.0.x.x |
3.0.0 |
Microsoft.AspNet.WebPages.WebData |
2.0.x.x |
3.0.0 |
Microsoft.AspNet.WebPages.OAuth |
2.0.x.x |
3.0.0 |
Microsoft.AspNet.Mvc |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.Mvc.Facebook |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.Core |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.SelfHost |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.Client |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.OData |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.WebHost |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.Tracing |
4.0.x.x |
5.0.0 |
Microsoft.AspNet.WebApi.HelpPage |
4.0.x.x |
5.0.0 |
Microsoft.Net.Http |
2.0.x. |
2.2.x. |
Microsoft.Data.OData |
5.2.x |
5.6.x |
System.Spatial |
5.2.x |
5.6.x |
Microsoft.Data.Edm |
5.2.x |
5.6.x |
Microsoft.AspNet.Mvc.FixedDisplayModes |
|
Removed |
Microsoft.AspNet.WebPages.Administration |
|
Removed |
Microsoft-Web-Helpers |
|
Microsoft.AspNet.WebHelpers |
4、更新根目录的web.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
< runtime > < assemblyBinding xmlns = "urn:schemas-microsoft-com:asm.v1" > <!--Two elements removed for Clarity --> < dependentAssembly > < assemblyIdentity name = "System.Web.Helpers" publicKeyToken = "31bf3856ad364e35" /> < bindingRedirect oldVersion = "1.0.0.0-3.0.0.0" newVersion = "3.0.0.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "System.Web.Mvc" publicKeyToken = "31bf3856ad364e35" /> < bindingRedirect oldVersion = "1.0.0.0-5.0.0.0" newVersion = "5.0.0.0" /> </ dependentAssembly > < dependentAssembly > < assemblyIdentity name = "System.Web.WebPages" publicKeyToken = "31bf3856ad364e35" /> < bindingRedirect oldVersion = "1.0.0.0-3.0.0.0" newVersion = "3.0.0.0" /> </ dependentAssembly > <!--WebGrease element removed for Clarity --> </assemblyBinding |
1
2
3
4
5
6
7
|
< appSettings > < add key = "webpages:Version" value = "3.0.0.0" /> < add key = "webpages:Enabled" value = "false" /> < add key = "PreserveLoginUrl" value = "true" /> < add key = "ClientValidationEnabled" value = "true" /> < add key = "UnobtrusiveJavaScriptEnabled" value = "true" /> </ appSettings > |
1
2
3
|
< securityPolicy > <!--<trustLevel name="Medium" policyFile="web_mediumtrust.config"/>--> </ securityPolicy > |
5、修改View文件夹下的web.config
1
2
3
4
5
6
7
8
9
|
< system.web.webPages.razor > < host factoryType = "System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> < pages pageBaseType = "System.Web.Mvc.WebViewPage" > < namespaces > < add namespace = "System.Web.Mvc" /> <!--Elements removed for Clarity.--> </ namespaces > </ pages > </ system.web.webPages.razor > |
1
2
3
4
5
6
7
8
9
10
11
|
--> < pages validateRequest = "false" pageParserFilterType = "System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType = "System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType = "System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" > < controls > < add assembly = "System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace = "System.Web.Mvc" tagPrefix = "mvc" /> </ controls > </ pages > </ system.web > |
1
2
3
4
5
6
7
|
< configuration > < configSections > < sectionGroup name = "system.web.webPages.razor" type = "System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" > < section name = "host" type = "System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission = "false" /> < section name = "pages" type = "System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission = "false" /> </ sectionGroup > </ configSections > |
6、右键解决方案,选择卸载项目
7、右键项目,编辑 [ProjectName].csproj
8、找到 ProjectTypeGuids 节,删除Guid
{E3E379DF-F4C6-4180-9B81-6769533ABE47},保存
9、右键项目,重新加载项目
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Asp.Net MVC4通过id更新表单内容的思路详解 2020-03-19
- mvc5 源码解析1:UrlRoutingModule 2019-07-23
- EIP权限工作流升级说明-2019/5/23 2019-05-23
- ASP.NET MVC5 高级编程-学习日记-第二章 控制器 2018-12-14
- ASP.NET MVC5 高级编程-学习日记-第一章 入门 2018-12-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash