MVC程序集版本不兼容问题

First Error:检测到 ASP.NET Web Pages 的冲突版本: 指定的版本为“2.0.0.0”,而 bin 中的版本为“1.0.0.0”。要继续操作,请删除应用程序 bin 目录中的文件,或者删除 web.config 中的版本指定。

English version:Conflicting versions of ASP.NET WebPages detected: specified version is"1.0.0.0", 
but the version in bin is"2.0.0.0".Tocontinue, remove files from the application's bin directory 
or remove the version specification in web.config.


解决方案:
1。Open 'Package Manager Console' in Visual Studio
2。uninstall-package microsoft.aspnet.mvc
3。install-package microsoft.aspnet.mvc

second Error:
System.Collections.Generic.Dictionary`2<System.String,BlockParser> System.Web.Razor.Parser.CSharpCodeParser.get_RazorKeywords()”。
这些所有的错误都是因为版本不兼容问题,如果你想在MVC3 的版本下运用 razor 2也是可以的

步骤:
First :you can have a reference of system.web.Helpers and system.web.webPages in your reference assembly

Second:in your ROOT web.config(the bottom one),do some changes,UPDATE OR ADD
 


<appSettings>
<add key="webpages:Version" value="2.0.0.0"/>
<add key="webpages:Enabled" value="true" /> <add key="PreserveLoginUrl" value="true" />

<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD

<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.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" />
</dependentAssembly>


Inside Views web.config file, add/update these settings,


 <configSections>
		<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<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" />
			<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" />
		</sectionGroup>
      </configSections>
      <system.web.webPages.razor>
		<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />



Now you can easily use Razor V2 features in inside ASP.NET MVC 3 view.



      @{
            int? nullValue = null;
      }

      <a href="~/WebForm1.aspx" class="@nullValue">MyLink</a>

 

Note: Before doing this, make sure you have installed ASP.NET MVC 4. Otherwise the trick will fail.

 

 

I must say the configuration of the Microsoft's platform is a little bit annoying.

 

These are  the problems that bothers me very much ,then I share it with all of you.

 

All the version is availablehere:https://nuget.org/packages/Microsoft.AspNet.Mvc/

 

















转载于:https://www.cnblogs.com/ifutan/archive/2013/06/08/using-razor-v2-in-asp-net-mvc-3.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值