aspnet-core-3-signup-verification-api icon indicating copy to clipboard operation
aspnet-core-3-signup-verification-api copied to clipboard

How to add the Authentication to other controllers

Open hussainsam opened this issue 3 years ago • 1 comments

Hi, if we are using another controller, adding [authorize] to the controller or adding app.UseAuthentication or app.UseAuthorization would just wouldn't work. It just throws this error No authenticationScheme was specified, and there was no DefaultChallengeScheme found. Can you tell me how can I pass your AccountsController to my other controllers.

hussainsam avatar May 15 '21 20:05 hussainsam

@hussainsam This is because you have an [Authorize] attribute on a controller somewhere that is referencing the Authorize class in 'Microsoft.AspNetCore.Authorization' namespace rather than the namespace of the custom authorize attribute.

Make sure to remove all usings for 'Microsoft.AspNetCore.Authorization' from your controllers and then make sure you are using the namespace where the custom authrorize attribute is located

hedgybeats avatar Jul 30 '21 09:07 hedgybeats