Home > Articles > Details

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?


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.


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

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

Merry said:

Thank you,

Posted On: August 22, 2022 16:30:36 PM

© 2022 - ErnesTech - Privacy