Razor 带有剃须刀的Servicestack不工作->禁用的资源
我正在失去理智。。。想在我的Win 8.1机器上的空web应用程序中使用SS Razor功能。通过NuGet安装,在根目录下添加了一个网页,出现以下错误:Razor 带有剃须刀的Servicestack不工作->禁用的资源,razor,servicestack,servicestack-razor,Razor,servicestack,Servicestack Razor,我正在失去理智。。。想在我的Win 8.1机器上的空web应用程序中使用SS Razor功能。通过NuGet安装,在根目录下添加了一个网页,出现以下错误: >Forbidden >Request.HttpMethod: GET >Request.PathInfo: /default.cshtml >Request.QueryString: >Request.RawUrl: /default.cshtml >App.DebugLastHandlerArgs:
>Forbidden
>Request.HttpMethod: GET
>Request.PathInfo: /default.cshtml
>Request.QueryString:
>Request.RawUrl: /default.cshtml
>App.DebugLastHandlerArgs: >GET|/default.cshtml|Z:\GIT\MasterThesis\src\AppBlue\AppBlue.Web\default.cshtml
我还试用了SS的Razor rockstars示例应用程序,效果非常好。
所以我复制了web.config,但没有成功。还可以在集成模式下运行托管管道模式。
项目设置为.NET4.5。
当我部署到Azure时仍然无法工作
要完成此操作,请访问my 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>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<compilation targetFramework="4.5" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".cshtml" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
<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>
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="AppBlue.Web" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
</system.web.webPages.razor>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings>
</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, Version=3.0.0.0" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0" requirePermission="false" />
</sectionGroup>
</configSections>
感谢您的帮助!
祝你一切顺利
更新
AspNet.webpage的安装版本是2,因此我通过NuGet安装了最新版本,并更改了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>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<compilation targetFramework="4.5" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".cshtml" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
<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>
<system.web.webPages.razor>
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="AppBlue.Web" />
</namespaces>
</pages>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
</system.web.webPages.razor>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings>
</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, Version=3.0.0.0" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0" requirePermission="false" />
</sectionGroup>
</configSections>
它现在可以正常工作了,但我的自定义路径->api似乎不起作用
<?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, Version=3.0.0.0" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0" requirePermission="false" />
</sectionGroup>
</configSections>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5"/>
</system.Web>
-->
<location path="api" >
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
</location>
<system.web>
<compilation targetFramework="4.5" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".cshtml" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings><system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="AppBlue.Web" />
</namespaces>
</pages>
</system.web.webPages.razor></configuration>
其余调用只能在根路径上工作。可以启用,然后查看?debug=requestInfoThank,无法加载System.Web.Razor,正如您在此处看到的,但不知道如何解决?请参阅上的wiki,也许您可以简要说明System.Web.WebPages.Razor,System.Web.Razor和SS.Razor有关联吗?为什么RazorRockstars在没有给出版本信息的情况下工作?