Reputation: 73908
I'm using MVC 3 and Razor as View Engine, for my understanding HTML tags are decoding by default to prevent XSS attacks or similar. (I'm also using MS XSS 4.2.1 Library)
I have a View showing some data
<div class="display-label">Code</div>
<div class="display-field">
@Html.DisplayFor(model => model.Code).
</div>
Model.Code is HTML code for some Banners, I need to display the HTML on the page DECODED.
My question: How can I decode the HTML for just model.Code
living the rest ENCODED?
Thanks for your help
Upvotes: 3
Views: 3946
Reputation: 21442
you can use to output the data as is without encoding :
@Html.Raw(model.Code)
Upvotes: 1
Reputation: 7443
To display raw html use
@Html.Raw(model.Code)
Be extremely careful though
Upvotes: 3