/// <summary> /// 获得指定Url参数的值 /// </summary> /// <param name="strName">Url参数</param> /// <param name="sqlSafeCheck">是否进行SQL安全检查</param> /// <returns>Url参数的值</returns> public static string GetQueryString(string strName, bool sqlSafeCheck) { if (HttpContext.Current.Request.QueryString[strName] == null) { return(""); } if (sqlSafeCheck && !AngelUtils.IsSafeSqlString(HttpContext.Current.Request.QueryString[strName])) { return("unsafe string"); } return(HttpContext.Current.Request.QueryString[strName]); }
/// <summary> /// 获取IP通用方法 /// </summary> /// <returns></returns> public static string GetIP() { string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (string.IsNullOrEmpty(result)) { result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } if (string.IsNullOrEmpty(result)) { result = HttpContext.Current.Request.UserHostAddress; } if (string.IsNullOrEmpty(result) || !AngelUtils.IsIP(result)) { return("127.0.0.1"); } return(result); }
/// <summary> /// 获得指定Url参数的int类型值 /// </summary> /// <param name="strName">Url参数</param> /// <param name="defValue">缺省值</param> /// <returns>Url参数的int类型值</returns> public static int GetQueryInt(string strName, int defValue) { return(AngelUtils.StrToInt(HttpContext.Current.Request.QueryString[strName], defValue)); }