如何德code HTML在MVC剃刀 [英] How Decode HTML in MVC with RAZOR
本文介绍了如何德code HTML在MVC剃刀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用MVC 3剃须刀作为视图引擎,为我的理解HTML标签被默认为prevent XSS攻击或类似的解码。 (我还使用MS XSS 4.2.1库)
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>
模型。$ C $ c是HTML code一些横幅,我需要显示的页面DE codeD上的HTML。
我的问题:?我如何去code中的HTML只是模型code
生活其余EN $ C $的cD
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?
感谢您的帮助。
推荐答案
要显示原始HTML使用
To display raw html use
@Html.Raw(model.Code)
要特别小心,虽然
Be extremely careful though
这篇关于如何德code HTML在MVC剃刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文