zoukankan      html  css  js  c++  java
  • 防止sql注入统一验证

    static string str = "|add|and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join|";
        public static bool DataVerify()
        {
            string type = HttpContext.Current.Request.RequestType.ToLower();
            bool flag = true;
            if (type == "post")
            {
                for (int i = 0; i < HttpContext.Current.Request.Form.Count; i++)
                {
                    string value = HttpContext.Current.Request.Form[i].ToString().Trim();
                    if (str.Contains("|" + value + "|"))
                    {
                        flag = false;
                    }
                }
            }
            else if (type == "get")
            {
                for (int i = 0; i < HttpContext.Current.Request.QueryString.Count; i++)
                {
                    if (str.Contains("|" + HttpContext.Current.Request.QueryString[i].ToString().Trim() + "|"))
                    {
                        flag = false;
                    }
                }
            }
            else
            {
                flag = false;
            }
            return flag;
        }

  • 相关阅读:
    2月5号:linux运维shell
    linux命令go on
    2月6日:linux下命令与查看方式
    AHU_OJ 08
    AHU_OJ 57
    javascript学习笔记2
    javascipt学习笔记1
    javascript学习笔记4
    javascript学习笔记3
    未能加载文件或程序集“”或它的某一个依赖项。系统找不到指定的文件
  • 原文地址:https://www.cnblogs.com/ajun/p/2913599.html
Copyright © 2011-2022 走看看