private static void RejectRequest(ActionExecutingContext context, InvalidRecaptchaResponseMode mode) { const string msg = "ReCaptcha header is empty"; switch (mode) { case InvalidRecaptchaResponseMode.ThrowRecaptchaException: throw new RecaptchaMissingException(msg); case InvalidRecaptchaResponseMode.ReturnBadRequest: context.Result = new BadRequestObjectResult(new { error = msg }); break; } }
private static async Task RejectRequestAsync(HttpContext httpContext, InvalidRecaptchaResponseMode mode) { const string msg = "ReCaptcha header is empty"; switch (mode) { case InvalidRecaptchaResponseMode.ThrowRecaptchaException: throw new RecaptchaMissingException(msg); case InvalidRecaptchaResponseMode.ReturnBadRequest: httpContext.Response.StatusCode = 400; await httpContext.Response.WriteAsync(JsonConvert.SerializeObject(new { msg })); break; } }