剃刀主机厂错误 [英] Razor Host Factory error
问题描述
我得到一个错误MvcWebRazorHostFactory试图运行我的应用程序,但它不是一个MVC应用程序在所有。我已经通过的NuGet安装了以下网络包:
I get a MvcWebRazorHostFactory error trying to run my app, but it's not an MVC app at all. I have the following web packages installed via nuget:
Microsoft ASP.NET Razor
Microsoft ASP.NET Web API 2.1
Microsoft ASP.NET Web Pages
我的应用程序是使用剃刀视图(.cshtml)angularjs前端。我不明白为什么我不断收到此错误。
My app is angularjs front end using razor views (.cshtml). I don't understand why I keep getting this error.
An exception of type 'System.InvalidOperationException' occurred in System.Web.WebPages.Razor.dll but was not handled in user code
Additional information: Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
这是我的web.config剃刀部分:
And here is the razor section in my web.config:
<system.web.webPages.razor>
<host factoryType="System.Web.WebPages.Razor.WebRazorHostFactory, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.WebPages.WebPage">
<namespaces>
<add namespace="System.Web.Configuration" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
推荐答案
我通过设置解决了这个问题, System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc
版本到5.2.0.0和它的工作,终于来了!为什么5.2.0.0?相同版本的NuGet的Microsoft ASP.NET项目。所以,在/Views/Web.Config行是:
I resolved this issue by setting System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc
Version to 5.2.0.0 and it worked, finally! Why 5.2.0.0? Same version as NuGet Microsoft ASP.NET project. So, the line in /Views/Web.Config looks:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
这篇关于剃刀主机厂错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!