Abp框架下 Area中新建Layout报错的问题
ABP框架下,新建Admin的Area。
在Area中定义底层Layout报错,原因为@ApplicationPath无法解析:
<script type="text/javascript">
//This is used to get the application's root path from javascript. It's useful if you're running application in a virtual directory under IIS.
var abp = abp || {}; abp.appPath = '@ApplicationPath';
</script>
解决方法:
修改Admin下的WebConfig文件为:
<?xml version="1.0"?>
<configuration>
<configSections>
<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>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="WebMonitor.Web.Views.WebMonitorWebViewPageBase">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="WebMonitor.Web" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<!--<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />-->
</handlers>
</system.webServer>
</configuration>
主要是为了设置pageBaseType属性为:WebMonitor.Web.Views.WebMonitorWebViewPageBase,
View继承了此类后即可解析:@ApplicationPath
浙公网安备 33010602011771号