0
votes

I have configured a MVC site to use windows authentication in the project properties and in the config file:

WEB CONFIG

<authentication mode="Windows"/>
  <authorization>      
      <allow users="domain_name\rbello"/>
      <deny users="?" />
  </authorization>

View Controller

 [Authorize (Users=@"domain_name\rbello, domain_name\svinstall")] 
 [Authorize(Roles = @"domain_name\administrators")]
        public ActionResult ForAdmin()
        {
           return View();
        }

When I run the code on my machine through IISExpress or when I deploy the site to IIS i get the login window but after I sign in I get an error stating "HTTP Error 401.0 - Unauthorized You do not have permission to view this directory or page"

I made sure Windows Authentication is enabled in IIS features on the project as well as on the IIS server for Windows Authentication. I also set NTLM as first provider as some had say to do. Not sure what else I been at this for a couple days now, appreciate any help!

.NET Framework 4.5 IIS 7.5 MVC 4

1
Can you remove the Authorization attribs and see if you can get to the page just to make sure your routing is correct and the IIS bindings are configured? IISExpress uses a dynamic port.Kevin Raffay
Which attribute the authorization in web config or controller?milltonion

1 Answers

0
votes

I corrected this I had a mistakenly a User value for a Role attribute example
Incorrect: [Authorize(Roles = @"domain_name\administrators")] Corrected to: [Authorize(Roles = @"Administrators")]