首页 技术 正文
技术 2022年11月23日
0 收藏 317 点赞 4,551 浏览 4067 个字

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

?

1234567891011121314151617 <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

?

1234567 <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>

?

123   <securityPolicy>   <!--<trustLevel name="Medium"  policyFile="web_mediumtrust.config"/>--></securityPolicy>

5、修改View文件夹下的web.config

?

123456789 <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>

?

1234567891011   -->  <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>

?

1234567 <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、右键项目,重新加载项目

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,910
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,435
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,250
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,061
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,693
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,731