Html Encoded Code Expressions
-
05-07-2019 - |
Question
In ASP.NET 4.0
should I use new syntax <%: expression %>
or 2.0 <%= HttpUtility.HtmlEncode(expression) %>
Solution
Less keystrokes, less chance to make a mistake, easier to read => use the first option.
OTHER TIPS
That's sort of like asking if you should do this:
<%= DateTime.Now %>
or this
<% Response.Write(DateTime.Now) %>
There's no right answer, but one certainly looks better to me.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow