1

Hi I'm trying to use actionmailer standalone in a WCF service and everything works according to plan when it comes to substituting data using Model.XXX.

The problem starts when I try parsing templates using @Html

I receive : Unable to compile template. The name 'Html' does not exist in the current context

example template the works:

Hello @Model.Name

template failing

Hello @Model.Name
@Html.CheckBox("test")

So how can HtmlHelpers be used with actionmailer in a standalone scenario?

tereško
  • 58,060
  • 25
  • 98
  • 150
Anders Nilsson
  • 1,465
  • 12
  • 12
  • Press F12 on the `Model` property to see the underlying razor object of your webpage. There will or will not be the `Html` property. – AgentFire Nov 04 '13 at 17:18
  • The problem is not the Model object the variable substitutions are ok , but HTML helpers doesn't appear to be recognized the problem starts when @Html is included and the view gets an error Unable to compile template. The name 'Html' does not exist in the current context – Anders Nilsson Nov 04 '13 at 18:15

1 Answers1

0

Ensure you have the web.config file inside your Views folder which helps the razor engine to have some extensions you might use:

<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, 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.Optimization"/>
      <add namespace="System.Web.Routing" />
    </namespaces>
  </pages>
</system.web.webPages.razor>
AgentFire
  • 8,944
  • 8
  • 43
  • 90