开发者

Should we use encoding for HtmlString?

开发者 https://www.devze.com 2023-01-31 03:41 出处:网络
What\'s better in ASP.NET MVC <%= Html.LabelForModel() %> or <%: Html.LabelForModel() %&g开发者_C百科t;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消