c# - How can I show a viewbag as html? -


OK, ASP.NET is quite new to MVC, so I'm sorry if this is a stupid question, but I How to show the value of a viewback as HTML, for example, if ViewBag.SomeMessage has the following text:

& lt; H3 & gt; Test & lt; / H3 & gt; & Lt; P & gt; Test & lt; / P & gt; & Lt; P & gt; Test & lt; / P & gt; & Lt; P & gt; Test & lt; / P & gt; & Lt; P & gt; Test & lt; / P & gt; & Lt; P & gt; Test & lt; / P & gt;

Actually render the page as HTML? Or is it a very easy way to completely disappear?

Cheers!

Everyone is correct in using the @ html.Raw () But I want to ask for caution because it can make your site susceptible to XSS vulnerabilities.

I will add @ html.Raw (ViewBag.SomeMessage) to ensure that you will not present any weaknesses to it.

EDIT: The benefit of the anti-XSS library (if you have not seen it), its approved markup (such as b & gt; , & lt; h3 & gt; , etc.) so that only approved markups will be un-encoded.

Edit2: How it is done.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -