数据库字段包含HTML显示原始文本 [英] Database field containing HTML display raw text

查看:231
本文介绍了数据库字段包含HTML显示原始文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.Net MVC3使用C#

ASP.Net MVC3 using c#

目前,我有我的应用程序存储HTML数据库字段,但是当我尝试使用显示HTML领域。

I currently have a database field in my application that stores HTML but when I try to display the HTML field using.

@Html.DisplayFor(model => model.game_description)

目前的HTML被显示为纯文本我怎么得到它正确显示HTML?

Currently the HTML is being displayed as plain text how do I get it to render the HTML properly?

推荐答案

您的意思是不HTML编码吗?您可以使用 Html.Raw 助手:

You mean without HTML encoding it? You could use the Html.Raw helper:

@Html.Raw(Model.game_description)

和警告,并充分了解有关执行此操作的后果:你的网站变得容易受到 XSS攻击。所以一定要确保你知道这个HTML的由来。

And be warned and fully aware about the consequences of doing this: your site becomes vulnerable to XSS attacks. So make sure you know the origin of this HTML.

这篇关于数据库字段包含HTML显示原始文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆