ASP.NET MVC - How to send html from controller to view

I have HTML text stored in a database. Now what I want to do is get this text and send it as all html formatting. But all I get is: and lt; p and gt;

This is not exactly what I want. Any ideas on how to get

+3
source share
2 answers

HTML not encoded in view:

Razor:

@Html.Raw(Model.SomeHtmlStringComingFromTheDatabase)

WebForms:

<%= Model.SomeHtmlStringComingFromTheDatabase %>

Note: by doing this, you acknowledge that you fully understand the consequences of XSS attacks , that your application becomes vulnerable, and that you are doing the necessary to sanitize this HTML if it comes from user input.

+9
source

Html.Raw() .

0

All Articles