开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜