I recently noticed that I had a big hole in my application because I had done something like:
<input type="text" value="<%= value%>" />
I know that I should have used Html.Encode
, but is there any way to do that for all values, without having to do it explicitly?
There's a few ways:
<%: %>
syntax in ASP.NET MVC2 / .NET 4.0. (Which is just syntactic sugar for Html.Encode()
)