3

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

2 Answers 2

9

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Take a look at using Html.Raw() in your view.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.