Beispiel #1
0
        /// <summary>
        /// 获得验证码图片
        /// </summary>
        /// <returns></returns>
        public ActionResult GetYZMImage()
        {
            YZMHelper yzmhelper = new YZMHelper();

            MemCacheHelper2.Instance.Cache.Set("yzmCode_" + Session.SessionID, yzmhelper.Text, DateTime.Now.AddMinutes(30));
            //log.Error("页面SessionID" + Session.SessionID);
            return(File(yzmhelper.GetVaildateBytes(), "image/Jepg"));
        }
        /// <summary>
        /// 获得验证码图片
        /// </summary>
        public HttpResponseMessage GetYZMImage()
        {
            YZMHelper yzmhelper = new YZMHelper();
            var       userGuid  = CookieOper.Instance.GetUserGuid();

            MemCacheHelper2.Instance.Cache.Set("yzmCode_" + userGuid, yzmhelper.Text, DateTime.Now.AddMinutes(30));
            var resp = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(yzmhelper.GetVaildateBytes())
            };

            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
            return(resp);
        }