61,827
社区成员




if (ChkBadWord(Request.QueryString.ToString()))
{
Response.Write("<script language='javascript'>alert('参数中存在非法数据');history.back();</script>");
Response.End();
}
// 检测字符串中是否有非法的字符,如果有,返回true
public bool ChkBadWord(string badword)
{
string[] bw = strbadword();
bool isok = false;
foreach (string str in bw)
{
if (badword.IndexOf(str) > -1)
{
isok = true;
return isok;
}
}
return isok;
}
private string[] strbadword()
{
string[] bad = new string[15];
bad[0] = "'";
bad[1] = "\"";
bad[2] = ";";
bad[3] = "--";
bad[4] = ",";
bad[5] = "!";
bad[6] = "~";
bad[7] = "@";
bad[8] = "#";
bad[9] = "$";
bad[10] = "%";
bad[11] = "^";
bad[12] = "&";
bad[13] = " ";
bad[14] = "_";
return bad;
}