Should we use encoding for HtmlString?
What's better in ASP.NET MVC
<%= Html.LabelForModel() %>
or
<%: Html.LabelForModel() %&g开发者_C百科t;
? Why?
If it returns MvcHtmlString it won't matter; the <%:
will know it is pre-escaped. I would therefore use <%:
as then the reviewer doesn't need to think "is this escaped? or is this a raw field?".
Of course, that does depend on the code that creates the MvcHtmlString being sane...
Neither is "better". They both output the same exact markup.
精彩评论