/// <summary> /// 登录验证码 /// </summary> public void VerifyCode_GET() { if (Cms.RunAtMono) { return; // mono下字体无法识别 } string word = null; VerifyCodeGenerator v = new VerifyCodeGenerator(); try { FontFamily f = VerifyCodeGenerator.GetFontFamily(); Font font = new Font(f, 16); v.AllowRepeat = false; Response.BinaryWrite(v.GraphicDrawImage(4, VerifyWordOptions.Letter, !true, font, 50, out word)); VerifyCodeManager.AddWord(word); Response.ContentType = "Image/Jpeg"; } catch (Exception exc) { throw exc; } }
/// <summary> /// 验证码 /// </summary> /// <param name="context"></param> public void VerifyCode(HttpContext context) { string word = null; VerifyCode v = new VerifyCode(); var font = v.GetDefaultFont(); try { font = new System.Drawing.Font(font.FontFamily, 16); v.AllowRepeat = false; context.Response.BinaryWrite(v.GraphicDrawImage(4, VerifyWordOptions.Number, !true, font, 30, out word)); } catch { if (font != null) { font.Dispose(); } } context.Response.ContentType = "Image/Jpeg"; VerifyCodeManager.AddWord(word); }
/// <summary> /// 登录验证码 /// </summary> public void VerifyCode() { string word = null; var v = new VerifyCodeGenerator(); Response.ContentType("Image/Jpeg"); var f = GetCodeFontFamily(); var font = new Font(f, 16); v.AllowRepeat = false; var code = v.GenerateVerifyWords(4, VerifyWordOptions.Letter); Response.WriteAsync(v.GraphicDrawImage(code, !true, font, 50)); VerifyCodeManager.AddWord(new string(code)); }