Reputation: 1239
I have text formated with HTML saved in database. Now what I want to do is to get that text and send it view, with all html formating. But all I get is: & lt; p & gt;
Which is no exactly what I want. Any ideas how to get
Upvotes: 3
Views: 2324
Reputation: 1038810
Don't HTML encode in the view:
Razor:
@Html.Raw(Model.SomeHtmlStringComingFromTheDatabase)
WebForms:
<%= Model.SomeHtmlStringComingFromTheDatabase %>
Remark: by doing this you acknowledge that you fully understand the consequences of XSS attacks that your application becomes vulnerable to and that you do the necessary to sanitize this HTML if it comes from user input.
Upvotes: 9