Tom*_*Tom 6 c# razor servicestack
我已经将SS.Razor安装到我的测试项目中.如果我只是更改default.htm - > cshtml,它可以工作,但没有vs intellisense语法支持.因此剃刀代码是纯文本黑色和白色.
我想知道如何在不打开作为.net MVC项目的项目的情况下打开Razor.谢谢!
编辑------------------------------------------
这是我的web.config
(注意add extension =".cshtml"......有...)
<?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, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings>
<connectionStrings />
<!--
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>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="Backbone.Todos" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
Run Code Online (Sandbox Code Playgroud)
为了在VS.NET中获得智能,您的ASP.NET Web应用程序需要注册必要的构建提供程序,告诉VS.NET编译器razor视图,要包含的基类以及要添加的命名空间.您可以在Razor Rockstars示例项目中找到必要的Web.Config 示例.
注意:当您创建自托管控制台应用程序时,您还需要存储在Web.config中的App.Config的副本(这是VS.NET在设计时查看的内容).在开发/设计时间之外不需要或使用Web.config.
安装ServiceStack.Razor NuGet包时,应该已经自动包含必要的web.config信息.因此,如果您删除了应用于Web.config 的web.config转换,则需要将其添加回来.如果要手动复制web.config.transform文件,则需要$rootnamespace$使用项目命名空间手动修改占位符,例如更改:
<add namespace="$rootnamespace$" />
Run Code Online (Sandbox Code Playgroud)
至
<add namespace="Amce.MyWebProject" />
Run Code Online (Sandbox Code Playgroud)
嗯,看起来在VS 2012上可能存在一个关于智能的突出问题,你需要恢复使用VS2010,直到我们弄清楚VS.NET团队用Razor的构建提供商改变了什么.
| 归档时间: |
|
| 查看次数: |
1911 次 |
| 最近记录: |