Nancy(基于asp.net,net 4.5)使用视图或者不使用视图都是正常的,但是加载layout就不行。
Unable to locate layout: ~/Views/Shared/_Layout.cshtml
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: Unable to locate layout: ~/Views/Shared/_Layout.cshtml
web.config配置如下:
<configSections>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor"/>
<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="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false"/>
</sectionGroup>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor"/>
</configSections>
<system.web.webPages.razor>
<pages pageBaseType="Nancy.ViewEngines.Razor.NancyRazorViewBase">
<namespaces>
<add namespace="Nancy.ViewEngines.Razor"/>
</namespaces>
</pages>
</system.web.webPages.razor>
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="Nancy"/>
<add assembly="InstManagerNancy"/>
</assemblies>
</razor>