就像你回答我的问题,在文本框里输入内容,如带有("\n", "<br>");
(
string content = this.txtContent.Text.Trim();
content = content.Replace(" ", " ");
content = content.Replace("\n", "<br>");)
这里内容怎么转换危险字符?
谢谢!
(
string content = this.txtContent.Text.Trim();
content = content.Replace(" ", " ");
content = content.Replace("\n", "<br>");)
这里内容怎么转换危险字符?
谢谢!
protected void Page_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
Response.Write("请您输入合法字符串。");
Server.ClearError(); // 如果不ClearError()这个异常会继续传到Application_Error()。
}
} 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/intcry/archive/2010/12/23/6093455.aspx
Server.HtmlDecode()对输入内容进行编码解码页面显示可以把一个DIV设置为服务器控件就可以后台写了
DivName.InnerText
这样子出来脚本也不会运行!
DivName.InnerHtml(会运行脚本)
根本不需要替换的!
HttpContext.Current.Server.HtmlEncode编码
正则替换字符