通过HttpContext获得Boolean值

2017-01-25 17:12:56  访问(1521) 赞(0) 踩(0)


        /// <summary>
        /// 通过HttpContext获得Boolean值
        /// </summary>
        /// <param name="hc"></param>
        /// <param name="strName"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public bool HttpContextGetBoolean(string strName, bool defaultValue)
        {
            HttpContext hc = HttpContext.Current;

            if (hc == null)
                return defaultValue;

            string str = hc.Request[strName];

            if (str == "1")
                return true;

            if (str == "0")
                return false;

            return defaultValue;
        }


标签:通过HttpContext获得Boolean值 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)