public ActionResult GenerateValidCode() { var helper = new ValidateCodeHelper(); var data = helper.CreateValidateCode(); return(File(data, "image/gif")); }
public FileContentResult GetValidateCode() { ValidateCodeHelper vc = new ValidateCodeHelper(); string strValidateCode = vc.CreateValidateCode(4); Session["ValidateCode"] = strValidateCode; return(File(vc.CreateValidateGraphic(strValidateCode), "image/jpeg")); }
/// <summary> /// 图形验证码 /// </summary> /// <returns></returns> public IActionResult ValidateCode() { string code = ""; System.IO.MemoryStream ms = ValidateCodeHelper.CreateValidateCode(out code); Utility.SetSession("LoginValidateCode", code); Response.Body.Dispose(); return(File(ms.ToArray(), @"image/png")); }
public FileResult ValidateCode() { ValidateCodeHelper vCode = new ValidateCodeHelper(); string code = vCode.CreateValidateCode(5); TempData[VALIDATECODE] = code; byte[] bytes = vCode.CreateValidateGraphic(code); return(File(bytes, @"image/jpeg")); }
public ActionResult GetValidateCode() { var vCode = new ValidateCodeHelper(); string code = vCode.CreateValidateCode(4); Session["ValidateCode"] = code; byte[] bytes = vCode.CreateValidateGraphic(code); return(File(bytes, @"image/jpeg")); }
public ActionResult GetValidateCode() { ValidateCodeHelper codeHelper = new ValidateCodeHelper(); string strCode = codeHelper.CreateValidateCode(5); Session[Sessionvalues.LoginValideCode] = strCode; byte[] data = codeHelper.CreateValidateGraphic(strCode); return(File(data, "image/jpeg")); }
public IActionResult GetValidateCode() { string validateString = ValidateCodeHelper.CreateVaildateString(4); byte[] buffer = ValidateCodeHelper.CreateValidateCode(validateString); string ip = HttpContext.Connection.RemoteIpAddress.ToString(); MemoryCacheHelper.SetCache(ip, validateString); return(File(buffer, @"image/png")); }
public ActionResult GetValidateCode() { //创建验证码类的对象 ValidateCodeHelper code = new ValidateCodeHelper(); string strCode = code.CreateValidateCode(4);//生成验证码的长度 Session["validateCode"] = strCode; byte[] buffer = code.CreateValidateGraphic(strCode); return(File(buffer, "image/jpeg")); }
public byte[] GetVcode() { string strCode = ValidateCodeHelper.CreateValidateCode(4); //验证码放到Session里面去 SessionHelper.Session[APPKeys.Vercode] = strCode; byte[] imgBytes = ValidateCodeHelper.CreateValidateGraphic(strCode); return(imgBytes); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var valid = new ValidateCodeHelper(); string code = valid.CreateValidateCode(5); Session["validCode"] = code; var ImgCode = valid.CreateValidateGraphic(code); Response.ClearContent(); Response.ContentType = "image/gif"; Response.BinaryWrite(ImgCode); } }
public void ProcessRequest(HttpContext context) { var vCode = new ValidateCodeHelper(); string code = vCode.CreateValidateCode(5); context.Session["ValidateCode"] = code; byte[] bytes = vCode.CreateValidateGraphic(code); MemoryStream ms = new MemoryStream(bytes); Bitmap bitmap = new Bitmap(ms); bitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg); context.Response.ContentType = "image/jpg"; context.Response.End(); }