请问如何过滤掉危险的HTML代码啊
我用了
str=str.Replace("<","<");
str=str.Replace(">",">");
存入数据库的也是对的,可是只要我一加字母就报错
就是说输入"<"存入数据库的是"<",可是只要写成"<br"就报错
怎么弄啊?
我用了
str=str.Replace("<","<");
str=str.Replace(">",">");
存入数据库的也是对的,可是只要我一加字母就报错
就是说输入"<"存入数据库的是"<",可是只要写成"<br"就报错
怎么弄啊?
解决方案 »
- 关于读写文件内存耗尽的问题
- 由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题
- dev的xtrareport 自定义纸张打印问题?
- 急求HTTP协议问题
- 怎么在HTML代码中查找一串字符
- socket通信的时候为什么不能传输汉字
- 请问如何在父窗体接受window.open()的返回值
- 关于Response.Write("<script>confirm('你确定结贴?')</script>");的问题
- 数据库连接字符串Data Source赋值会自动改变
- 如何把double值的整数部分四舍五入 急。在线等
- SelectSingleNode ASP.NET XML的小问题
- 一个WinForm的显示问题,求助!!
HttpUtility.HtmlEncode(str);
用者俩
我听说要在HTML页面里面加一句什么代码还是什么的?
请问能指教下不
那两个方法是可以实现的你需求的
using System;
using System.Web;
using System.IO; class MyNewClass
{
public static void Main()
{
String myString;
Console.WriteLine("Enter a string having '&' or '\"' in it: ");
myString=Console.ReadLine();
String myEncodedString;
// Encode the string.
myEncodedString = HttpUtility.HtmlEncode(myString);
Console.WriteLine("HTML Encoded string is "+myEncodedString);
StringWriter myWriter = new StringWriter();
// Decode the encoded string.
HttpUtility.HtmlDecode(myEncodedString, myWriter);
Console.Write("Decoded string of the above encoded string is "+
myWriter.ToString());
}
}
是在PAGE里面加一句话