public ActionResult CreateVerifyCode() { string code = CaptchaHelper.CreateVerifyCode(4); MemoryStream ms = CaptchaHelper.CreateVerifyCodeImg(code); TempData["verifyCode"] = code; //Session["verifyCode"] = verifyCode; return(File(ms, "image/jpeg")); }
/// <summary> /// 获取验证码 /// </summary> /// <returns></returns> public ActionResult GetVerifyCode() { string code = CaptchaHelper.CreateVerifyCode(4); TempData["verifyCode"] = code; var stream = CaptchaHelper.CreateVerifyCodeImg(code); return(File(stream, "image/jpeg")); }
public ActionResult GetValidateCode() { try { CaptchaHelper captcha = new CaptchaHelper(); string code = captcha.CreateVerifyCode(4); byte[] bytes = captcha.CreateImageCode(code); return(File(bytes, "image/jpeg")); } catch (Exception ex) { return(Content(string.Format("{0}++++++{1}{2}", ex.Message, System.Environment.NewLine, ex.StackTrace))); } }