How to write a html field on asp.net MVC3 Razor

I have a String string on my model that contains an html value, my problem is that when I put the code to render this field in my view, it will be completely converted to html and the end result will be a large string with html characters, shielded ...

@field //= "<div>" 

is having

  &lt ;div&gt ; 

How can I override this behavior and make it write html unescaped in my field?

+6
source share
2 answers

You can use the Html.Raw :

 @Html.Raw(field) 
+15
source

Use @ Html.Raw:

 @Html.Raw(field) 
+3
source

Source: https://habr.com/ru/post/900920/


All Articles