Related to this question I play around with XSS issues in my ASP.NET MVC project and I´m confused with the MvcHtmlSTring.ToHtmlString() method. From the documentation "Returns an HTML-encoded string that represents the current object.", but it doesn´t work in my case:
var mvcHtmlString = MvcHtmlString.Create("<SCRIPT/XSS SRC=\"htpp://ha.ckers.org/css.js\">").ToHtmlString();
var encoded = HttpUtility.HtmlEncode("<SCRIPT/XSS SRC=\"htpp://ha.ckers.org/css.js\">");
Output of mvcHtmlString
<SCRIPT/XSS SRC="htpp://ha.ckers.org/css.js">
Output of encoded <-- this is the behaviour I would suspect!
<SCRIPT/XSS SRC="htpp://ha.ckers.org/css.js">
Did I miss something?