ASP.NET MVC3,Html.TextAreaFor没有编码? [英] ASP.NET MVC3, Html.TextAreaFor without encoding?

查看:105
本文介绍了ASP.NET MVC3,Html.TextAreaFor没有编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用它编码的Html.TextAreaForwithout?
我知道这是一个安全隐患,但我有一个单独的类进行消毒的任何文本。

How can I use the Html.TextAreaForwithout encoding it? I know it's a security risk but I have a separate class that sanitizes any text.

例如:

@ Html.TextAreaFor(型号=> model.PostBodyText,10,100,1)

@Html.TextAreaFor(model =>model.PostBodyText, 10, 100, 1)

我打算用TinyMCE的使用它。

I'm planning to use it with TinyMCE.

问候
乌鸦

更新
我使用新的Razor视图引擎。

UPDATE I'm using the new Razor View Engine.

推荐答案

您将需要推出自己的:

<textarea cols="100" id="PostBodyText" name="PostBodyText" rows="10">
    @MvcHtmlString.Create(Model.PostBodyText)
</textarea>

当然,在安全性方面这可能是非常危险的,因为你的网站是目前容易受到XSS攻击。所以,问题是,为什么有一个单独的类进行消毒的所有文字时,你可以简单地依靠HTML助手为你做这项工作?

Of course in terms of security this could be very dangerous as your site is now vulnerable to XSS attacks. So the question is why having a separate class that sanitizes all the text when you can simply rely on the HTML helpers to do the job for you?

这篇关于ASP.NET MVC3,Html.TextAreaFor没有编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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