我正在加载一个在IIS7和IIS6中使用BlogEngine4构建的博客,我已经完成了所有配置并通过谷歌帮助解决了所有可能性的问题。但我最终得到以下错误。谁有聪明的答案?
所有页面都正常加载,但只有在我加载.cshtml文件页面时才加载
服务器错误。Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
Exception Details: System.InvalidOperationException: Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
来源错误:
在执行当前Web请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息。
Stack Trace:
[InvalidOperationException: Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines]
System.Web.WebPages.Razor.WebRazorHostFactory.CreateFactory(String typeName) +178
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +64System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfigCore(RazorWebSectionGroup config, String virtualPath, String physicalPath) +201
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath, String physicalPath) +41
System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig(String virtualPath) +7
System.Web.WebPages.Razor.RazorBuildProvider.GetHostFromConfig() +16
System.Web.WebPages.Razor.RazorBuildProvider.CreateHost() +17
System.Web.WebPages.Razor.RazorBuildProvider.get_Host() +21
System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() +66
System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType() +39
System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider) +94
System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders() +207
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +41
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +658
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +360
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +107
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +96
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp) +13
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +45
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(String virtualPath, Type requiredBaseType) +23
System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType(String virtualPath) +228
System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +147
System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType(String virtualPath) +192
System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +74
System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) +24
System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath) +20
System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +250
System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +94
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +135
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +168
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272
答案 0 :(得分:1)
如果您尝试在Umbraco站点的虚拟目录中托管blogengine站点,则必须修改blogengine web.config以“删除”所有特定于Umbraco的处理程序和模块,因为这些将继承由blogengine应用程序引起此异常,因为应用程序无法在其bin文件夹中找到相关的DLL。
我最近有类似的问题,我发布了我在下面的虚拟目录中使用的web.config。我是一个非常简单的Web应用程序,所以很明显这在你的blogengine应用程序中无法自行运行。您需要将相关部分添加到web.config文件中。
此外,这是在IIS7.5中安装v6 Umbraco,因此您可能需要进行一些实验。
<?xml version="1.0"?>
<configuration>
<configSections>
<remove name="urlrewritingnet" />
<remove name="umbraco.presentation.Properties.Settings" />
<remove name="clientDependency" />
<remove name="Examine" />
<remove name="ExamineLuceneIndexSets" />
<remove name="FileSystemProviders" />
<remove name="log4net" />
<remove name="BaseRestExtensions" />
<remove name="system.web.webPages.razor" />
</configSections>
<appSettings>
<clear/>
</appSettings>
<system.web>
<httpModules>
<remove name="UrlRewriteModule" />
<remove name="UmbracoModule" />
<remove name="ClientDependencyModule" />
</httpModules>
<httpHandlers>
<remove verb="*" path="umbraco/channels.aspx" />
<remove verb="*" path="umbraco/channels/word.aspx" />
<remove verb="*" path="DependencyHandler.axd" />
<remove verb="GET,HEAD,POST" path="GoogleSpellChecker.ashx" />
</httpHandlers>
<compilation defaultLanguage="c#" debug="false" batch="false" targetFramework="4.0">
<buildProviders>
<remove extension=".cshtml" />
<remove extension=".vbhtml" />
<remove extension=".razor" />
</buildProviders>
</compilation>
<membership>
<providers>
<remove name="UmbracoMembershipProvider" />
<remove name="UsersMembershipProvider" />
</providers>
</membership>
<!-- added by NH to support membership providers in access layer -->
<roleManager enabled="false">
<providers>
<remove name="UmbracoRoleProvider" />
</providers>
</roleManager>
<!-- Sitemap provider-->
<siteMap defaultProvider="UmbracoSiteMapProvider" enabled="false">
<providers>
<remove name="UmbracoSiteMapProvider" />
</providers>
</siteMap>
</system.web>
<system.webServer>
<modules>
<remove name="UrlRewriteModule" />
<remove name="UmbracoModule" />
<remove name="ClientDependencyModule" />
</modules>
<handlers accessPolicy="Read, Write, Script, Execute">
<remove name="Channels" />
<remove name="Channels_Word" />
<remove name="ClientDependency" />
<remove name="SpellChecker" />
</handlers>
</system.webServer>
</configuration>
<强>更新强>
如果应用程序web.config中存在<system.web.webPages.razor>
部分,则可能还需要更新host
部分,将pages
和<host factoryType="System.Web.WebPages.Razor.WebRazorHostFactory,
System.Web.WebPages.Razor" />
<pages pageBaseType="System.Web.WebPages.WebPage">
条目更改回其默认值:
{{1}}
这是因为Umbraco实现了自己的hostfactory和页面基础。