I've read What is an MvcHtmlString and when should I use it? I did not understand the whole answer of Torbjörn Nomell. He wrote that "razor encodes everything by default." What does this mean?
Asked
Active
Viewed 72 times
1 Answers
3
He means that Razor will HTML-encode special characters. e.g.:
@{
var test = "<br>";
}
@test
Will yield:
<br>
If you want to write out the raw HTML (e.g. you are trying to render rich text with HTML formatting) you need to use Html.Raw
:
@Html.Raw(test);
Yields:
<br>

Ant P
- 24,820
- 5
- 68
- 105