I have a Model with property Content which contains HTML string.
var model = new { Content = ... } Razor.Parse(templateBody, model)
How can I render this string using standalone Razor.
I tried:
@(new HtmlString(Model.Content))
and also
@(HttpUtility.HtmlDecode(Model.Content))
Model.Content renders always HTML-escaped.
Escapes are very useful for representing characters that are not apparent or are ambiguous. Numeric or named character references, as well as CSS escapes, can be used to represent characters in HTML style attribute. The style element HTML can not contain numeric or named character references.
In Razor, `@` symbol is used to transition from HTML to C#. To escape an '@' symbol in razor markup, use two '@' symbols.
Razor is a markup syntax for embedding . NET based code into webpages. The Razor syntax consists of Razor markup, C#, and HTML. Files containing Razor generally have a . cshtml file extension.
this should work Html.Raw(Model.Content)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With