简体   繁体   中英

Configuring Windows Authentication with MVC (4)

While testing and developing on my local machine, code that I used to get my username on the domain with User.Identity.Name worked fine.

Now that I've published to our local server, the application keeps redirecting me to the /login.aspx?ReturnUrl= page, but I'm getting a 401 - Unauthorized error.

I can't figure out what to do next. Here's the steps I've taken so far:

  • Disabled Anonymous Authentication in IIS & my project properties
  • Added to the Web.config
  • Put [Authorize] on all my controllers
  • Enabled Windows Authentication on my project properties

If I run the site on the local server itself, the error is a bit more detailed:

HTTP Error 401.2 - Unauthorized
You are not authorized to view this page due to invalid authentication headers.

Then again I'm not sure if this error is different to the usual 401.

Any ideas?

Turns out the server I was publishing to didn't have the correct Authentication types installed. Resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM