Request对象功能封装类

public class Req
    {
        /// <summary>
        /// 获取Request对象值
        /// </summary>
        /// <param name="Key">键名</param>
        /// <returns></returns>
        public static string Value(string Key)
        {
            return HttpContext.Current.Request[Key];
        }
        /// <summary>
        /// 判断指定的Request是否存在
        /// </summary>
        /// <param name="Key">键名</param>
        /// <returns></returns>
        public static bool Exis(string Key)
        {
            try
            {
                if (HttpContext.Current.Request[Key] != null && HttpContext.Current.Request[Key].Trim().Length > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return true;
            }
        }
        /// <summary>
        /// 获取QuerString值进行对比;true(存在);false(不存在)
        /// </summary>
        /// <param name="Key">键名</param>
        /// <param name="Value">比较值</param>
        public static bool CompareTo(string Key, string Value)
        {
            try
            {
                if (HttpContext.Current.Request[Key].ToString() == Value)
                {
                    return true;
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
    }

posted @ 2010-06-24 12:14  davidDJT  阅读(372)  评论(0)    收藏  举报