asp.net - 基本或 Windows 身份验证的无限重定向循环?

标签 asp.net windows-server-2012 iis-8

我正在开发一个新的 ASP.NET 应用程序。在 IIS8 上,如果我禁用匿名访问并启用基本或 Windows 身份验证,它会进入无限重定向循环并在浏览器中断循环后登陆以下 URL:

https://XXXXXX.com/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525252FAccount%25252525252525252FLogin%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FAccount%2525252525252525252FLogin%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FAccount%252525252525252525252FLogin%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FAccount%25252525252525252525252FLogin%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FAccount%2525252525252525252525252FLogin%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FAccount%252525252525252525252525252FLogin%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FAccount%25252525252525252525252525252FLogin%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FAccount%2525252525252525252525252525252FLogin%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FAccount%252525252525252525252525252525252FLogin%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FAccount%25252525252525252525252525252525252FLogin%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252FAccount%2525252525252525252525252525252525252FLogin%2525252525252525252525252525252525253FReturnUrl%2525252525252525252525252525252525253D%252525252525252525252525252525252525252F

凭据框永远不会弹出。可能有什么问题?

最佳答案

我修好了它。您必须做的第一件事是在 IIS 和 Visual Studio 项目上启用 Windows 身份验证并禁用匿名(在解决方案资源管理器和属性窗口中选择根项目节点以禁用匿名访问并启用 Windows 身份验证)。接下来,将以下行添加到您的 web.config:

<system.webServer>
  <modules>
    <remove name="FormsAuthenticationModule" />
    <remove name="FormsAuthentication" />
  </modules>
</system.webServer>

接下来打开 App_Start/Startup.Auth.cs 并注释掉(或删除)以下内容:
        // Enable the application to use a cookie to store information for the signed in user
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login")
        });
        // Use a cookie to temporarily store information about a user logging in with a third party login provider
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

接下来,发布到您的网络服务器,您应该能够在没有重定向错误的情况下登录!

关于asp.net - 基本或 Windows 身份验证的无限重定向循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23065466/

相关文章:

websocket - 哪个版本的 SignalR 支持 WebSockets?

windows - 如何将 Windows 2003 Server 计划任务移动/复制到 Windows 2012 Server?

asp.net - Asp.Net WebForms 上的 MVP

asp.net - 即使我想使用 SQL 身份验证,Integrated Security=true 仍尝试使用我的 Windows 凭据记录我的日志

.net - .NET 中的 RIO(注册 I/O)套接字

iis - 信任来自 IIS 的自签名证书

php - Azure 网站 PHP 5.6 IIS 8.0 setlocale 函数问题

c# - 跨网络更新面板失败

c# - 加载此程序集会产生与其他实例不同的授权集

c# - 将原始数据发送到 Zebra TTP 2030 打印机并获取其状态