Exemple #1
0
        public async Task <IActionResult> Code()
        {
            string      code = $"{Thread.CurrentThread.ManagedThreadId} {DateTime.Now.Millisecond:D4}";
            CaptchaItem item = new CaptchaItem()
            {
                Code = code, SessionId = Guid.NewGuid()
            };

            byte[] buf = await _captchaService.CreateImageAsync(item);

            Response.Headers.Add("Session", $"{item.SessionId}");
            return(File(buf, "image/png"));
        }