using System;
using System.Collections.Generic;
using System.Text;
namespace HG.CommonLib
{
public class CheckQuery
{
/// <summary>
/// 检验网页参数是否存在和是否包含违法字符
/// </summary>
/// <param name="strQuery">参数名称</param>
/// <param name="strUrl">不符合要求后的转向地址</param>
public static void CheckQueryStr(string strQuery, string strUrl)
{
if (System.Web.HttpContext.Current.Request[strQuery] == null)
{
System.Web.HttpContext.Current.Response.Redirect(strUrl);
}
else
{
string strKey = "'";
if (System.Web.HttpContext.Current.Request[strQuery].ToString().IndexOfAny(strKey.ToCharArray()) != -1)
{
System.Web.HttpContext.Current.Response.Redirect(strUrl);
}
}
}
/// <summary>
/// 检测网页post过来的地址!
/// </summary>
/// <param name="FormQuery">要检测的关键字</param>
/// <param name="strUrl">如果不存在要转向的地址</param>
public static void CheckQueryFrom(string FormQuery, string strUrl)
{
if (System.Web.HttpContext.Current.Request.Form[FormQuery] == null)
{
System.Web.HttpContext.Current.Response.Redirect(strUrl);
}
}
}
}