/// <summary> /// 获取验证码 /// </summary> /// <returns></returns> public ActionResult GetVcode() { var code = VerifyCode.GenerateCheckCode(); Session["vCode"] = code; var byt = VerifyCode.CreateCheckCodeImage(code); return(File(byt, "image/jpeg")); }
//验证码<img alt="验证码" src="/VerificationCode/Index" id="code_img" title="看不清请点击!" /> // GET: /VerificationCode/ public ActionResult Index() { VerifyCode vc = new VerifyCode(); string num = vc.MakeValidateCode(); System.Web.HttpContext.Current.Session["code"] = num.ToLower();//写入session byte[] bytes = vc.CreateCheckCodeImage(num); return(File(bytes, @"image/jpeg")); }