App_Code/CheckQuery.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.Text;

namespace 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);
            }
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。