public ActionResult Add(string uid, string mail, string actualname, string idcard, string age) { if (Session["cheak1"].ToString() == "1") { Session["cheak1"] = "0"; string YZM = YZMHelper.GetRandomString(); Session["uid_1"] = uid; Session["YZM"] = YZM; Session["mail"] = mail.Trim(); Session["actualname"] = actualname; Session["idcard"] = idcard; Session["age"] = age; bool end1 = YiMailHelper.Mail_Uid_exist(uid, Session["mail"].ToString()); if (end1) { if (YiMailHelper.Mail(mail, Session["YZM"].ToString())) { return(View()); } else { return(Content("<script>alert('请输入正确的邮箱');window.location.href='../question/Index';</script>")); } } else { return(Content("<script>alert('你输入的用户名或者邮箱已经被使用');window.location.href='../question/Index';</script>")); } } else { return(View()); } }
/// <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")); }
public async Task <IActionResult> GetVerificationCode() { string code = string.Empty; var baseArr = YZMHelper.GetCode(out code); HttpContext.Session.Set("VerificationCode", Encoding.UTF8.GetBytes(code)); return(File(baseArr, "image/png")); }
/// <summary> /// 获取验证图片 /// </summary> /// <returns></returns> public ReResult get_LoginPic() { YZMHelper y = new YZMHelper(RandImg.Str); re.Code = 200; re.Message = y.base64; re.Remark = y.text; return(re); }
public string ValidateImage(HttpRequest req) { var yzm = new YZMHelper(); string code = yzm.CreateRandomCode(4); SessionHelper.SetSession("ValidateCode", code); string imgstr = yzm.GetValidateGraphicBase64String(code); return(imgstr); }
public ActionResult VerifyCode() { var codeInfo = new YZMHelper(); Session["Text"] = codeInfo.Text; MemoryStream ms = new MemoryStream(); codeInfo.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return(File(ms.ToArray(), @"image/Gif")); }
public ActionResult GetImgVerifyChars() { HttpContext.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //不缓存 YZMHelper yz = new YZMHelper(); yz.CreateImage(); HttpContext.Session.Add("CheckCode", yz.Text); HttpContext.Session.Timeout = 600; MemoryStream ms = new MemoryStream(); yz.Image.Save(ms, ImageFormat.Png); yz.Image.Dispose(); return(File(ms.ToArray(), @"image/jpeg")); }
/// <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); }
public ActionResult GetImgCode() { int width = 125; int height = 48; int fontsize = 22; string code = string.Empty; byte[] bytes = YZMHelper.CreateValidateGraphic(out code, 4, width, height, fontsize); var sessionid = HttpContextHelper.Current.Session.Id; CookieHelper.WriteCookie("sessionid", sessionid); RedisHelper.StringSet("imgcode:" + sessionid, code); return(File(bytes, @"image/jpeg")); }
//public ActionResult GetUserInfo() //{ // string ResultStr = string.Empty; // UserInfo u = new UserInfo(); // u.name = "andy"; // u.age = 12; // u.address = "xxxxx-12-111xxx"; // u.birthday = "2015-12-12"; // u.mark = "biezhu "; // u.modify = DateTime.Now.ToShortDateString(); // ResultStr = JsonTool.ObjToJson(u); // return Content(ResultStr); //} public ActionResult Yzm() { YZMHelper yzm = new YZMHelper(); yzm.CreateImage(); Session["vcode"] = yzm.Text.ToLower(); //Session中保存验证码 MemoryStream ms = new MemoryStream(); yzm.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return File(ms.ToArray(), @"image/jpeg"); }