I reuse the same partial for a RazorEngine email using RazorEngine.Parse, but when I use the same Partial in a regular view new RazorEngine.Text.RawString doesnt work and doesnt ignore HTML. I cant use Html.Raw because the RazorEngine cant read it. How can I get around this?
<p>
@(new RazorEngine.Text.RawString(Model.Body))
</p>
Shows the bottom markup in a regular asp.net mvc razor view.
<p>
Welcome!<br/><br/>Body
</p>
You can specify
ITemplateServiceConfigurationwhen creating an instance ofRazorEngineServiceas shown in project's git repository.Code from the Repository:
Usage:
Only thing you need to remember is to provide
ITemplateServiceConfigurationobject when creating an instance ofRazorEngineService.P.S:
@(new RazorEngine.Text.RawString(Model.Body))is not working in partial view because it is wrapped around@()and any string from the directive will be encoded before it is written to the output stream.