Home > database >  why it says access denied for roles="Admin"?
why it says access denied for roles="Admin"?

Time:07-27

I want to set Authorize tag in my controller and when I do so, it says that your access to that controller is denied. but in the database, everything looks good. then what is the problem? *I should mention that I use individual accounts authentication type

pic1

pic2

pic3

pic4

    [Authorize(Roles = "Admin")]
    public IActionResult ContactUs()
    {
        return View();
    }

CodePudding user response:

Try to log out from your application and log in again.

CodePudding user response:

You are probably missing role services

builder.Services.AddDefaultIdentity<IdentityUser>(...)
    .AddRoles<IdentityRole>()
...
  • Related