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

  • 相关阅读:
    c# udp局域网通信
    wpf 空白汉字占位符
    直角三角形知道变长求夹角
    windowsphone 的IsolatedStorageSettings存储类型
    WPFUIElement的Background的问题
    oracle外表
    oracle安装
    数据库ddl,dml,dcl
    OLTP与OLAP的介绍
    四种XML解析方式详解
  • 原文地址:https://www.cnblogs.com/ajun/p/2913599.html
Copyright © 2011-2022 走看看