Beispiel #1
0
        public static Bitmap GenerateCaptchaImage(string key)
        {
            var cSettings = (CaptchaSettings)HttpContext.Current.Session[key];
            var text      = CaptchaCode.GenerateCode(cSettings.TextLength, cSettings.TextStyle);

            cSettings.CaptchaText = text;
            return(new CaptchaImage().MakeCaptchaImge(text, cSettings.PicHeight - 10, cSettings.PicHeight - 1, cSettings.PicWidth, cSettings.PicHeight, cSettings.CaptchaStyle));
        }
Beispiel #2
0
 public async static Task <Bitmap> GenerateCaptchaImage(string key)
 {
     return(await Task.Run(() =>
     {
         var cSettings = AppContext.Current.Session.Get <CaptchaSettings>(key);
         var text = CaptchaCode.GenerateCode(cSettings.TextLength, cSettings.TextStyle);
         cSettings.CaptchaText = text;
         AppContext.Current.Session.Set <CaptchaSettings>(key, cSettings);
         return new CaptchaImage().MakeCaptchaImge(text, cSettings.PicHeight - 10, cSettings.PicHeight - 1, cSettings.PicWidth, cSettings.PicHeight, cSettings.CaptchaStyle);
     }));
 }