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:
Actually render the page as HTML? Or is it a very easy way to completely disappear? Cheers! Everyone is correct in using the I will add EDIT: The benefit of the anti-XSS library (if you have not seen it), its approved markup (such as Edit2: How it is done. & 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;
@ html.Raw () But I want to ask for caution because it can make your site susceptible to XSS vulnerabilities.
@ html.Raw (ViewBag.SomeMessage) to ensure that you will not present any weaknesses to it.
& lt; h3 & gt; , etc.) so that only approved markups will be un-encoded.
Comments
Post a Comment