问题描述
我遇到以下错误:
我已经在stackoverflow上搜索了类似的问题,并且使用了他们的解决方案,但似乎并不能解决我遇到的问题.
I have searched across stackoverflow for similar issues and I used their solutions but it doesn't seem to fix the issue I am experiencing.
突然发生,我按了干净的解决方案,然后弹出此错误.我还开始在解决方案上使用nuget软件包还原.我也更新了我的软件包(使用Update-package),因此其中一个可能与此问题有关.
It suddenly occurred, I just pressed clean solution and this error popped up. I also started using nuget package restore on the solution. I updated my packages as well (using Update-package) so one of those might have something to do with this issue.
推荐答案
此错误的原因是引用了System.Web.WebPages.Razor,版本= 2.0.0.0而不是3.0.0.0的Views文件夹中的web.config.
The cause of this error is the web.config in the Views folder referencing System.Web.WebPages.Razor, Version=2.0.0.0 instead of 3.0.0.0.
通常,这可能是在nuget-package升级后发生的,这并不说明该文件夹.
Typically this can happen after a nuget-package upgrade, which does not account for this folder.
更新 Views \ Web.config
文件:
<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>
有关升级到MVC 5的更多信息, http://www.asp.net/mvc/tutorials/mvc-5/how-to-将aspnet-mvc-4-和web-api-project升级到aspnet-mvc-5-和web-api-2
for more information on upgrading to MVC 5 http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2
这篇关于[A] System.Web.WebPages.Razor.Configuration.HostSection无法转换为... web.config问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!