You need to html decode your string.
Use System.Web.HttpUtility.HtmlDecode
for this.
System.Web.HttpUtility.HtmlDecode("<script>alert();'</script>")
will result in
<script>alert();'</script>
TextBoxFor does not support this, you have 2 options
1. Decoding before display
@{ Model.Description = System.Web.HttpUtility.HtmlDecode(Model.Description); } @Html.TextBoxFor(model => model.Description)
2. Use @ Html.TextBox for this
@Html.TextBox("Description", System.Web.HttpUtility.HtmlDecode(Model.Description))
hope this helps
dknaack
source share