/// <summary> /// 生成图片验证码 /// </summary> /// <param name="httpResponse"></param> /// <param name="guid"></param> /// <param name="length"></param> /// <returns></returns> public static void GenerateImageCode(this HttpResponse httpResponse, string guid, int length = 4) { var bytes = VerifyCodeHelper.GenerateImageCode(guid, length); httpResponse.Headers.Add("Access-Control-Expose-Headers", "X-VGuid"); httpResponse.Headers.Add("X-VGuid", guid); httpResponse.ContentType = "image/png"; httpResponse.StatusCode = StatusCodes.Status200OK; httpResponse.Body.WriteAsync(bytes, 0, bytes.Length); }