/// <summary> /// 生成验证码 /// </summary> public string CreateCheckCodeImage2() { var checkCode = CheckCodeHelper.GenerateCheckCode(); HttpCookie hc1 = new HttpCookie(SessionKey.ManagerUserLoginCode, checkCode); hc1.Expires = DateTime.Now.AddMinutes(10); HttpContext.Current.Response.Cookies.Add(hc1); var bytes = CheckCodeHelper.CreateCheckCodeImage(checkCode); return(Convert.ToBase64String(bytes)); }
/// <summary> /// 生成验证码 /// </summary> public void CreateCheckCodeImage() { var checkCode = CheckCodeHelper.GenerateCheckCode(); HttpCookie hc1 = new HttpCookie(SessionKey.ManagerUserLoginCode, checkCode); hc1.Expires = DateTime.Now.AddMinutes(10); HttpContext.Current.Response.Cookies.Add(hc1); var bytes = CheckCodeHelper.CreateCheckCodeImage(checkCode); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ContentType = "image/jpg"; HttpContext.Current.Response.BinaryWrite(bytes); }