简体   繁体   中英

Windows authentication username and password when trying to access MVC4 app in IIS6

I have just been banging my head against a brick wall all afternoon with this annoying problem. My deployed MVC app wasn't working on my server. When I tried to access the site I was getting the windows auth username and password box.

I couldn't for the life of me figure out why, and googling produced no answers to my problem. Everything was along the lines of 'enable anonymous users in IIS'. All my settings were correct in IIS were correct and I couldn't figure out what the hell was going on.

I figured it out and though I'd post a Q&A on here in the hope that one day it may save someone the tears of anger and frustration I have faced today.

In the end it was my own foolishness that was causing this problem.

The site was using Forms Authentication, and my controllers were decorated with the [Authorize] attribute.

However, during the deployment to my server and amongst the config transformations my build configuration was doing, the <authentication> section in the web config was being lost, so when the controller with the [Authorize] attribute was being hit, ASP.NET didn't know what sort of authentication to use so it was falling back on integrated windows authentication!

Just stick in authentication attribute back in and it should work.

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