剃刀 – ActionMailer.Net独立:没有为扩展名’.cshtml’注册的构建提供程序

前端之家收集整理的这篇文章主要介绍了剃刀 – ActionMailer.Net独立:没有为扩展名’.cshtml’注册的构建提供程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要从 Windows服务发送电子邮件,并发现了 ActionMailer.net,一个模板化的电子邮件系统,可以在ASP.Net MVC应用程序中使用或独立使用. @H_403_2@遵循独立教程

@H_403_2@http://geeksharp.com/2011/07/06/actionmailer-0-6-released/

@H_403_2@我正在创建一个视图.但是,当我在视图中输入任何文本时,它带有蓝色的波浪下划线.鼠标悬停在蓝色的波纹上,显示工具提示中的错误消息:

@H_403_2@There is no build provider registered for the extension ‘.cshtml’ You can register one in the <compilation><buildProviders> section of machine.config or web.config

@H_403_2@似乎我错过了设置剃须刀支持的步骤.

@H_403_2@我失踪了什么

解决方法

这只是一个警告.当你运行它的时候,你的项目将会被编译并且工作得很好.现在为了在ASP.NET MVC应用程序之外获得对您的Razor模板的工具支持,您可以查看 following blog post. @H_403_2@所以为了欺骗Visual Studio(愚蠢的)Intellisense只需在Windows服务项目的根目录中放置一个web.config(yeah web.config),具有以下内容

<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,PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection,PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc,Version=3.0.0.0,PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <system.web>
    <compilation targetFramework="4.0">
      <assemblies>
        <add assembly="System.Web.Mvc,PublicKeyToken=31bf3856ad364e35" />
      </assemblies>
    </compilation>
  </system.web>
</configuration>
@H_403_2@在运行时,这绝对是不必要的,当然没有任何效果(你的应用程序也在工作之前).这只是为了诱骗VS认为这是一个Web应用程序,并为您提供Intellisense.

原文链接:https://www.f2er.com/html/230360.html

猜你在找的HTML相关文章