Windows Authentication works in IISExpress but not

2020-07-25 09:24发布

问题:

I am having an odd issue. I am using the newest MVC5 in Visual Studio 2013. I am trying to create a site that hosts an anonymous API as well as an Admin dashboard that requires intranet domain credentials through Windows Authentication. Everything works when running through IIS Express like I expect but not when hosted in real IIS.

When hosted in real IIS it gives me a logon box like I expect for the Admin portion but it doesn't take my logon and keeps prompting me. I know it is the right username and password for sure. Any idea why this is happening?

I have Windows Authentication installed in Windows Features and turned on in IIS for the site and all that.

Below is my setup..

[Authorize]
public class DashboardController : Controller

<add key="EnableSimpleMembership" value="false" />

<authentication mode="Windows"/>
<authorization>
   <allow users="?" />
</authorization>
</system.web>
  <location path="gsapi">
    <system.webServer>
      <security>
        <authentication>
          <anonymousAuthentication enabled="true"/>
          <windowsAuthentication enabled="true"/>
        </authentication>
      </security>
    </system.webServer>
  </location>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

回答1:

There is a security feature that tries to intercept reflection attacks on your server. These attacks are basically a "man in the middle" attack where the attacker performs a challenge-response protocol to the two participating systems who are attempting to authenticate.

When your server is using host names mapped to the loopback address, the security feature that is trying to protect you against these attacks is not able to tell legitimate requests from fraudulent ones. The symptom is that all challenge response attempts will fail.

Your choices are to specify host names in your registry, or to disable the loopback check (not recommended).

The KB article that was linked in the comments gives specific instructions on what changes to make to work around this problem: http://support.microsoft.com/kb/896861