使用Windows身份验证,但是重定向到表单身份验证登录页面?

Rya*_*ers 1 asp.net iis-7 forms-authentication windows-authentication windows-server-2008-r2

我们正在运行IIS7并启用了Windows身份验证.其他一切都被禁用了.当我们转到页面时,我们不会提示我们进行Windows登录,但是会被重定向到默认的表单身份验证登录页面(帐户/登录?ReturnUrl =%2f).

有任何想法吗?谢谢.

Reb*_*cca 6

除此之外:

<authentication mode="Windows"></authentication>
<authorization>
  <allow users="*"/>
</authorization>
Run Code Online (Sandbox Code Playgroud)

你也可能也需要这两个appSettings:

<appSettings>
  <add key="autoFormsAuthentication" value="false" />
  <add key="enableSimpleMembership" value="false"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)

请参阅MVC3发行说明中有关SO已知问题的答案.


pan*_*del 5

如果有人做到了这一点并且其他答案尚未解决问题,请检查项目的 App_Code 文件夹中名为 Startup.Auth.cs 的文件。在我的情况下,下面的代码块处于活动状态并导致重定向到我不想使用的登录页面。

    // Enable the application to use a cookie to store information for the signed in user
    // and also store information about a user logging in with a third party login provider.
    // This is required if your application allows users to login
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Account/Login")
    });
    app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Run Code Online (Sandbox Code Playgroud)