Reputation: 259
I have seen the following tag as an answer to a question:
<%: Model.FirstName %>
what does " <%: " do?
Upvotes: 7
Views: 1172
Reputation:
There is some useful information for this: http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx
Upvotes: 2
Reputation: 4817
It html encodes the output of Firstname, this prevents encoding attacks like cross-side scripting (XSS).
Html encoded:
<%: Model.FirstName %>
Normal output:
<%= Model.FirstName %>
More info can by found at this blog post:
New <%: %> Syntax for HTML Encoding Output in ASP.NET 4 (and ASP.NET MVC 2)
Upvotes: 6