Add a way to access reason of a Mvc filter failure (ex: AntiforgeryTokenAuthorizationFilter.cs)
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
When `AntiforgeryValidation` fails, there is no way to track back the reason of the failure from `UseStatusCodePages` Handlers. This would be useful, to take the right action from client side.
From : ValidateAntiforgeryTokenAuthorizationFilter.cs
```
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (IsClosestAntiforgeryPolicy(context.Filters) && ShouldValidate(context))
{
try
{
await _antiforgery.ValidateRequestAsync(context.HttpContext);
}
catch (AntiforgeryValidationException exception)
{
_logger.AntiforgeryTokenInvalid(exception.Message, exception);
context.Result = new BadRequestResult();
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.