mvc 4 Project upgraded to mvc5, mvcmvc5

Source: Internet
Author: User mvc 4 Project upgraded to mvc5, mvcmvc5
I. Start

1. Open or create an mvc 4 Project

2. Modify the global. asax File





3. Delete the following ASP. NET NuGet packages and remove them using the Package Manager Console (PMC ).

Uninstall-Package -Id Microsoft.AspNet.WebPages.AdministrationUninstall-Package -Id Microsoft-Web-HelpersUninstall-Package -Id Microsoft.AspNet.Mvc.FixedDisplayModes

4. Update ASP. NET NuGet packages



2. Update Application web. config
<runtime>  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">    <!--Two elements removed for Clarity -->    <dependentAssembly>      <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />      <bindingRedirect oldVersion="" newVersion="" />    </dependentAssembly>    <dependentAssembly>      <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />      <bindingRedirect oldVersion="" newVersion="" />    </dependentAssembly>    <dependentAssembly>      <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />      <bindingRedirect oldVersion="" newVersion="" />    </dependentAssembly>    <!--WebGrease element removed for Clarity -->  </assemblyBinding


Modify <etettings>

<appSettings>    <add key="webpages:Version" value="" />    <add key="webpages:Enabled" value="false" />    <add key="PreserveLoginUrl" value="true" />    <add key="ClientValidationEnabled" value="true" />    <add key="UnobtrusiveJavaScriptEnabled" value="true" />  </appSettings>

Modify securityPolicy

<securityPolicy>   <!--<trustLevel name="Medium"  policyFile="web_mediumtrust.config"/>--></securityPolicy>
3. Update Web. config 


 <pages      validateRequest="false"      pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"      pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"      userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">    <controls>      <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />    </controls>  </pages></system.web>


<configuration>  <configSections>    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />    </sectionGroup>  </configSections>

Install Microsoft-Web-Helpers

Install-Package -Id Microsoft.AspNet.WebHelpers

If it is useful to User. IsInRole (), add the following code:

<system.webServer>    <modules>      <remove name="RoleManager" />    </modules>  </system.webServer>
Iv. Final

Modify ProjectName. csproj

FindProjectTypeGuidsElement and remove: MVC 4 project GUID,{E3E379DF-F4C6-4180-9B81-6769533ABE47}

Reload the project, compile, and succeed.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.