Some configuration issues with MVC Project Migration (GO)

Source: Internet
Author: User

This article transferred from: http://www.th7.cn/Program/net/201404/192102.shtml

With the version of VS and. NET MVC, EF is constantly updated, although it is more comprehensive with the release of the upgrade, but the old version of the development of software is a bit sad, perhaps many developers have encountered a similar problem!

Recently, a project was developed using. NET mvc3+ext.net MVC (which was configured using the ext.net MVC configuration (2) in this blog), and now it's going to be ported to the MVC4 environment, and there are all sorts of problems that are almost gone, and now it's time to summarize:

1. asp. NET Web Pages version issue

Browser Prompt after debugging:

conflicting versions of ASP: The specified version is "1.0.0.0" and the version in Bin is "2.0.0.0". To continue, delete the files in the application Bin directory or delete the version designation in Web. config.

Solve:

Web. config under configuration item

<appSettings>
<add key= "webpages:version" value= "2.0.0.0"/>
<add key= "clientvalidationenabled" value= "true"/>
<add key= "unobtrusivejavascriptenabled" value= "true"/>
</appSettings>

2. System.Web.WebPages.Razor.Configuration.HostSection version Issue

Browser Prompt after debugging:

[a]system.web.webpages.razor.configuration.hostsection cannot be cast to [B] System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from "System.Web.WebPages.Razor, version=1.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35" (In the context "Default" In the "c:/windows/microsoft.net/assembly/gac_msil/system.web.webpages.razor/v4.0_1.0.0.0__31bf3856ad364e35/ System.Web.WebPages.Razor.dll "location). Type B originates from "System.Web.WebPages.Razor, version=2.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35" (In the context "Default" In the "c:/windows/microsoft.net/assembly/gac_msil/system.web.webpages.razor/v4.0_2.0.0.0__31bf3856ad364e35/ System.Web.WebPages.Razor.dll "location).

Solve:

Configure Web. config in view

<section name= "host" type= "System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, version=2.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35 "requirepermission=" false "/>

3, System.Web.WebPages.Razor.Configuration.RazorPagesSection

Version issue

Browser Prompt after debugging:

[a]system.web.webpages.razor.configuration.razorpagessection cannot be cast to [B] System.Web.WebPages.Razor.Configuration.RazorPagesSection. Type A originates from "System.Web.WebPages.Razor, version=1.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35" (In the context "Default" In the "c:/windows/microsoft.net/assembly/gac_msil/system.web.webpages.razor/v4.0_1.0.0.0__31bf3856ad364e35/ System.Web.WebPages.Razor.dll "location). Type B originates from "System.Web.WebPages.Razor, version=2.0.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35" (In the context "Default" In the "c:/windows/microsoft.net/assembly/gac_msil/system.web.webpages.razor/v4.0_2.0.0.0__31bf3856ad364e35/ System.Web.WebPages.Razor.dll "location).

Solve:

Configure Web. config in view

<section name= "pages" type= "System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35 " Requirepermission= "false"/>

4,System.Web.Mvc.MvcWebRazorHostFactory

Version issue

An expression of type ' System.Web.Mvc.MvcWebRazorHostFactory ' cannot be used for return type ' System.Web.WebPages.Razor.WebRazorHostFactory '

Solve:

Web. config under configuration item

<runtime>
<assemblybinding xmlns= "Urn:schemas-microsoft-com:asm.v1" >
<!--<dependentAssembly>
<assemblyidentity name= "SYSTEM.WEB.MVC" publickeytoken= "31bf3856ad364e35"/>
<bindingredirect oldversion= "1.0.0.0-2.0.0.0" newversion= "3.0.0.0"/>
</dependentAssembly>-->
<dependentAssembly>
<assemblyidentity name= "System.Web.Helpers" publickeytoken= "31bf3856ad364e35"/>
<bindingredirect oldversion=" 1.0.0.0-2.0.0.0 "newversion=" 2.0.0.0 "/>
Span style= "color: #ff0000;" > </dependentassembly>
<dependentassembly>
<assemblyidentity name= "SYSTEM.WEB.MVC" publickeytoken= "31bf3856ad364e35"/>
<bindingredirect oldversion=" 1.0.0.0-4.0.0.0 "newversion=" 4.0.0.0 "/>
Span style= "color: #ff0000;" > </dependentassembly>
<dependentassembly>
<assemblyidentity name= "System.Web.WebPages" publickeytoken= "31bf3856ad364e35"/>
<bindingredirect oldversion= "1.0.0.0-2.0.0.0" newversion= "2.0.0.0"/>
</dependentassembly>
</assemblybinding>

</runtime>

Note: Blue for the original configuration, plus red this paragraph will not report the above error!

The above version of the problem as long as the red section of the configuration to the corresponding DLL in the bin file version number.

The above problem is the MVC3 configuration porting to Mvc4 error, with the advent of VS2013 and MVC5, there may be more problems, later encountered a supplement.

Some configuration issues with MVC Project Migration (GO)

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: info-contact@alibabacloud.com 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.