Mvc authorization attribute not working AspNet 6

Question: Why is an Asp.Net Core Authorization attribute not working, I have another Controller that utilizes Authorization and the implementation works pretty well. Why is the other Controller working and the other not?

Please Login to see the rest of the answer

Answer: Look carefully and examine the underlying API the [Authorization] attribute is using, there is a big chance that the Controller that has an Authorization Attribute that is not working is using a System.Web.Http API to Authorize, hence the Controller that has Authorization working usese a "Microsoft.AspNetCore.Authorization", this API works perfectly with the Web Application because the Web Application utilizes AspNetCore API.

You will need to refactor your code after removing the System.Web.Http Namespace from the upper top Class. I hope this helps to resolve your problem.

Another Article Here.

Write an Article
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

© 2022 - ErnesTech - Privacy