views:

49

answers:

1

what is <%: %> do in asp.net mvc?

+9  A: 

It HTML-encodes the output.

RedFilter
There was a presentation on MVC 2 where someone (ScottGu?) explained that if you take the equal sign in `<%= %>` and turn it sideways like you're closing a gate, you get `<%: %>` XD
Cogwheel - Matthew Orlando
It looks like an open gate to me, e.g., if you swing the closed gate (=) towards yourself 90 degrees. Maybe you're opening the gate to let all the safety in...
RedFilter
Right, so <%: "hello world" %> would be the equivalent of <%= Html.Encode("hello world") %>. Less code.I believe there is also a new MvcHtmlString type which "knows" whether it has already been encoded -- helps to avoid double-encoding.
Matt Sherman