1.出错页面提示:
“/”应用程序中的服务器错误。
[A]System.Web.WebPages.Razor.Configuration.HostSection 无法强制转换为 [B]System.Web.WebPages.Razor.Configuration.HostSection。类型 A 源自“System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”(在上下文“Default”中的“C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll”位置处)。类型
B 源自“System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”(在上下文“Default”中的“C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\df3b3b82\8328d46a\assembly\dl3\d0db8c7b\307d3d4f_b5d5cd01\System.Web.WebPages.Razor.dll”位置处)。
2.原因分析:本地程序集和GAC的程序集冲突了。
3.解决办法:
①修改文件~\Views\Web.config:
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
其实就是将引入程序集的PublicKeyToken置空。
②修改文件:~\Web.config:
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<!--这行要改-->
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" />
<!--这行要改-->
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</assemblies>
</compilation>
③修改后,重新生成并运行,就可以调试MVC源代码了。
分享到:
相关推荐
包括System.Web.WebPages.Razor.dll, System.Web.WebPages.Deployment.dll, System.Web.Mvc.dll, System.ComponentModel.DataAnnotations.dll, Microsoft.Web.Infrastructure.dll, System.ComponentModel....
ASP.NET Web Pages with Razor Syntax ASP.NET MVC 3
Senparc.Weixin.MP Senparc.Weixin.MP.MvcExtension Senparc.Weixin.Open System.Net.Http System.Web.Helpers System.Web.Mvc System.Web.Razor System.Web.WebPages.Razor
Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0
【ASP.NET编程知识】ASP.NET MVC学习教程之Razor语法.docx
RazorHtmlMinifier.Mvc5是为.NET v4.5构建的,它依赖于ASP.NET MVC 5.2.3和System.Web 。 配置 使用Razor配置查找Web.config (默认情况下,它位于Views/Web.config )。 您应该在内部看到以下内容: < host ...
ASP.NET MVC 4 and the Web API: Building a REST Service from Start to Finish helps you build cutting-edge REST services using ASP.NET MVC 4 and the Web API in more depth and detail than any other ...
jqGrid in ASP.NET MVC 3 and Razor.zipjqGrid in ASP.NET MVC 3 and Razor.zipjqGrid in ASP.NET MVC 3 and Razor.zip
The ASP.NET MVC 5 Framework is the latest evolution of Microsoft’s ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven ...
增删改查 登录功能 注册功能 新手上路必备 此项目有后台
MVC 3.0很适合适合初学者入门 一、MVC 3.0 的新特性................................................................................................................ 1 二、MVC 的概念及MVC 3.0 开发环境........
ASP.NET MVC、Web API、网页和 Razor 应用程序:注意:此存储库适用于 ASP.NET MVC 5.x、Web API 2.x 和 Web Pages 3.x。 对于 ASP.NET Core MVC,请查看。 ASP.NET MVC 是一个 Web 框架,它为您提供了一种强大的、...
ASP.NET Core 2.0 MVC Razor Pages
This one hundred page book focuses exclusively on how you can best use the ASP.NET MVC 4 Framework to build world-class REST services using the Web API. It sets aside much of what the ASP.NET MVC ...
The ASP.NET MVC 5 Framework is the latest evolution of Microsoft’s ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven ...
asp.net VC3宠物商店 项目源码 vs2010 razor 包含数据库,解压后什么都不用改, 直接可以运行的
The ASP.NET MVC 5 Framework is the latest evolution of Microsoft’s ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven ...
ASP.NET Web Pages – 添加 Razor 代码 在本教程中,我们将使用 C# 和 Visual Basic 代码的 Razor 标记。 什么是 Razor ? Razor 是一种将基于服务器的代码添加到网页中的标记语法 Razor 具有传统 ASP.NET 标记...
如果在使用VS2015等更高版本的时候出现“File not Found Exception Cannot Load System.Web.Razor.dll Version=2.0.0”这样的错误,请换用下面附件中的程序集把旧的RazorEginee.dll删掉,然后把 RazorEngine.NET4.0....
资源类型:程序源代码 源码说明: MVC 音乐店是用来介绍和展示使用 ASP.NETMVC 以及 Visual Studio 进行 Web 开发的示例应用程序,我们将从基础知识开始,一步一步地进行介绍,因此,初学者也可以去的很好的学习体验...