Should we use encoding for HtmlString?

What is better in ASP.NET MVC

<%= Html.LabelForModel() %> 

or

 <%: Html.LabelForModel() %> 

? Why?

+4
source share
3 answers

If it returns an MvcHtmlString, it does not matter; <%: will know that it is pre-shielded. Therefore i would use <%: since the reviewer should not think, "is it shielded?" Or is it an unprocessed field? "

Of course, it depends on the code that creates the correct MvcHtmlString ...

+5
source

Nothing is better. They both output the exact same markup.

0
source

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


All Articles