Is it possible to set a breakpoint on the [Authorize] Atrribute in my class? It has been causing Bad Request errors and I was wondering what inside the [Authorize] Attribute is causing it to do that.
Alternatively, is it possible to overwrite the [Authorize] Attribute and keep the originals functions after my conditions?
I get the BadRequest errors due to the way I am logging in as shown in this question: .NET Core 2.2 Shared Cookie causes Bad Request error when logging in
EDIT: Added Custom Authorize Attribute
public class ExtendedAuthorizeAttribute : AuthorizeAttribute { public async Task OnAuthorizationAsync(AuthorizationFilterContext authorizationFilterContext) { if (authorizationFilterContext.HttpContext.User.Identity.IsAuthenticated == false) { base.Function(); } } } 2 Answers
Is it possible to set a breakpoint on the [Authorize] ?I'm afraid impossibleIs it possible to overwrite the [Authorize] Attribute and keep the originals functions after my conditions?Yes, you can call the base class functions by usingbase.Function()
You cannot put a breakpoint inside the default [Authorize] filter, but you could debug the incoming request by providing your own AuthenticateAsync and inspect your request until you find out the problem.
The following snippet is from Authentication Filters in ASP.NET Web API 2.
public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { // 1. Look for credentials in the request. HttpRequestMessage request = context.Request; AuthenticationHeaderValue authorization = request.Headers.Authorization; 1