gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 20:25:19 25 4
gpt4 key购买 nike

我正在开发一个新的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com