HTMLEn code / HTMLDe code和撇号ASP.net [英] HTMLEncode/HTMLDecode and the apostrophe ASP.net

查看:172
本文介绍了HTMLEn code / HTMLDe code和撇号ASP.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文本框,允许用户输入内容存储在数据库中,然后从数据库中检索该值,并将其显示另一文本框。目前,我有这样的事情:

I have text box that allows the user to enter something which is stored in the database, and then another text box which retrieves this value from the database and displays it. Currently, I have something like this:

 string text = Server.HTMLDecode(userEnteredText);
 //code to put this text into the database

 Textbox1.Text = Server.HTMLDecode(textFromDatabase);

该Server.HTMLDe code解决,如果用户输入'字符遇到的任何问题。

The Server.HTMLDecode solves any problems encountered if a user enters the ' char.

不过,我如果用户输入&放大器;#39注意到到文本框中,然后ASP给出了一个错误反复思考客户正在进入有潜在危险的文字。反正是有解决这个?我注意到的,这是自动变成省略号大多数网站。任何想法如何我这样做是为了避免用户输入的问题?

However, I noticed if a user enters "&#39" into the textbox, then ASP gives a error again thinking the client is entering potentially dangerous text. Is there anyway around this? I notice on most sites that this is automatically turned into a apostrophe. Any idea how I do this to avoid user input problems?

推荐答案

如果你确定你想要这个,然后设置这在你的的web.config

If you're sure you want this, then set this in your web.config:

<system.web>
    <httpRuntime requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>

这篇关于HTMLEn code / HTMLDe code和撇号ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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