示例#1
0
 /// <summary>
 /// 获取指定表单参数的值
 /// </summary>
 /// <param name="key">表单参数</param>
 /// <param name="sqlSafeCheck">是否进行Sql安全检查</param>
 /// <returns>表单参数的值</returns>
 public static string GetFormParam(string key, bool sqlSafeCheck)
 {
     if (HttpContext.Current.Request.Form[key] == null)
     {
         return(string.Empty);
     }
     if (sqlSafeCheck && !ValidateKit.IsSafeSqlString(HttpContext.Current.Request.Form[key]))
     {
         return(string.Empty);
     }
     return(HttpContext.Current.Request.Form[key]);
 }
示例#2
0
        /// <summary>
        /// 将long型数值转换为Int32类型
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static int SafeInt32(object target)
        {
            if (target == null)
            {
                return(0);
            }
            string numString = target.ToString();

            if (ValidateKit.IsNumeric(numString))
            {
                if (numString.Length > 9)
                {
                    if (numString.StartsWith("-"))
                    {
                        return(int.MinValue);
                    }
                    return(int.MaxValue);
                }
                return(Int32.Parse(numString));
            }
            return(0);
        }