例如,当用户将HTML的标签插入文本框时,如何处理
问题描述:
当用户将HTML的标签插入文本框时的处理方式,例如,插入br< br/>
asp.net显示错误.
how to handle when User inter Tag of Html into Textbox for example Insert br <br/>
asp.net show Error.
how to Handle it?
答
在页面中放入ValidateRequest ="false",例如...
<%@页面标题=""ValidateRequest =" false语言=" C#"MasterPageFile ..."
这样可以防止抛出错误.但这也为攻击者提供了向应用程序中注入脚本的机会,因此,您还应该使用Server.HtmlEncode()保护您的页面
希望对您有帮助
Put ValidateRequest="false" in your page, like ...
"<%@ Page Title="" ValidateRequest="false" Language="C#" MasterPageFile..."
This will prevent throwing error. But this also open an opportunity for an attacker to inject script in you application, so you should also use Server.HtmlEncode() to protect your page
Hope this will help you