将我网站上的 ServiceStack 库从 3.9.71 升级到 4.0.33 后,我注意到 ServiceStack.Razor 不再正确呈现页面。它似乎没有读取 layout.cshtml 文件。页面加载时没有布局,也没有错误或警告。我尝试将 layout.cshtml 文件放在 /Views/_layout.cshtml 和 /Views/Shared/_layout.cshtml 中。
除了在升级过程中替换软件包之外,我还对 Web.config 文件进行了必要的更改。这是我的 Web.config 文件中的一个片段。请让我知道这是否有帮助,或者我是否需要提供其他信息。任何帮助,将不胜感激。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="webPages:Enabled" value="false" />
<add key="servicestack:license" value="{LICENSE_KEY_HERE}" />
</appSettings>
<system.webServer>
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<modules>
<add name="RightsModule" type="UI.security.RightsHttpModule" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.google.com" />
</conditions>
<action type="Redirect" url="http://google.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Required for MONO -->
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="1048576" />
<httpModules>
<add name="RightsModule" type="UI.security.RightsHttpModule" />
<add name="Airbrake" type="SharpBrake.NotifierHttpModule, SharpBrake" />
</httpModules>
<httpHandlers>
<!-- razor -->
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
<remove path="*.asmx" verb="*" />
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" />
<compilation targetFramework="4.5.1" debug="true">
<assemblies>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<!-- add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/ -->
</assemblies>
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<authentication mode="Forms">
<forms loginUrl="/optimize/login.cshtml" protection="All" timeout="1440" name="AudiencePoint" path="/app" requireSSL="false" slidingExpiration="true" defaultUrl="/optimize" cookieless="UseCookies" enableCrossAppRedirects="false" />
</authentication>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="UI" />
<add namespace="System" />
<add namespace="ServiceStack" />
</namespaces>
</pages>
</system.web.webPages.razor>
<location path="optimize">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
</configuration>