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?

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.

Edit this Article
Authorization AspNet 6 MVC ebook e-book .NET 6 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

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

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy