In my app I have a rich text editor (tinyMCE). I want to take the HTML output from there and insert into a MVC Postal email object and schedule via Hangfire.
Whilst I have this process working as expected the Html is not rendering.
Unfortunately I can't use Html.Raw(string) as its not available when Hangfire runs.
I get the exception:
RazorEngine.Templating.TemplateCompilationException
Unable to compile template. The name 'Html' does not exist in the current context Other compilation errors may have occurred. Check the Errors property for more information.
RazorEngine.Templating.TemplateCompilationException: Unable to compile template. The name 'Html' does not exist in the current context
Other compilation errors may have occurred. Check the Errors property for more information. at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Compilation\DirectCompilerServiceBase.cs:line 108 at RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 256 at RazorEngine.Templating.TemplateService.GetTemplate[T](String razorTemplate, Object model, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 374 at RazorEngine.Templating.TemplateService.GetTemplate(String razorTemplate, Object model, String cacheName) in c:\Users\abbottm\Documents\GitHub\RazorEngine\src\Core\RazorEngine.Core\Templating\TemplateService.cs:line 352
Any ideas?
Since Postal uses RazorEngine to render the Razor views, you must use @Raw(Model.Message)
if you want to directly add HTML to the view without it being escaped.