.net OWIN/IdentityServer登录陷入无休止的循环

.net OWIN/IdentityServer登录陷入无休止的循环,.net,asp.net-mvc,owin,identityserver2,.net,Asp.net Mvc,Owin,Identityserver2,我有一个工作正常的IdentityServer2身份验证服务器。我正在创建一个新的.NETMVC应用程序,并按照本文()的说明使用IDS2设置MS OWIN。我可以到达登录屏幕,但登录后,用户会被发送回呼叫网站,陷入无休止的循环 Startup.Auth.cs using Microsoft.Owin.Security; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.WsFederation; using

我有一个工作正常的IdentityServer2身份验证服务器。我正在创建一个新的.NETMVC应用程序,并按照本文()的说明使用IDS2设置MS OWIN。我可以到达登录屏幕,但登录后,用户会被发送回呼叫网站,陷入无休止的循环

Startup.Auth.cs

using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.WsFederation;
using Owin;

namespace AZBarMail
{
    public partial class Startup
    {
        public void ConfigureAuth(IAppBuilder app)
        {
            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

            app.UseCookieAuthentication(
                new CookieAuthenticationOptions
                {
                    AuthenticationType =
                       WsFederationAuthenticationDefaults.AuthenticationType
                });
            app.UseWsFederationAuthentication(
                new WsFederationAuthenticationOptions
                {
                    MetadataAddress = "https://auth.azbar.org/federationmetadata/2007-06/federationmetadata.xml",
                    Wtrealm = "https://localhost:44310/",
                });
        }
    }
}
web.config的一部分

<system.web>
  <authentication mode="None" />
  <compilation debug="true" targetFramework="4.6.1" />
  <httpRuntime targetFramework="4.6.1" />
</system.web>
IDS2中的重定向URL

https://localhost:44310/

将用户重定向到/account/login

app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/account/Login"),
                CookieName = CookieAuthenticationDefaults.CookiePrefix + "SampleClient",
                ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter,
                LogoutPath = new PathString("/account/Logout")
            });

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
从/account/login重定向到外部提供程序


externalprovider将在其域上创建cookie,您将在收到外部提供程序的响应后在域上创建cookie。

问题最终得到解决。cookie类型/设置似乎有问题。

但如果我的站点中没有名为/account/Login的内容,该怎么办?我从项目中删除了所有登录页面,因为登录都是在SSO站点上处理的。我不能从主页重定向回我的主页吗?SSO在其域上创建一个cookie,在您的站点域上创建另一个cookie,因此SSO页面需要被告知重定向uri,以便SSO可以重定向回您的页面,并且您可以在您的域上创建cookie。您是否还记得您在这里到底做了什么?“我现在面临着同样的问题。@Drew,我的cookies/authtoken只被发送到xxx.net域。这个域中的任何人都没有获得令牌,因此这些用户陷入了一个循环。就我而言,我已经从其他web应用程序中获得了另一个登录帐户。在隐姓埋名的浏览器模式下一切正常时发现了它。
app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/account/Login"),
                CookieName = CookieAuthenticationDefaults.CookiePrefix + "SampleClient",
                ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter,
                LogoutPath = new PathString("/account/Logout")
            });

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);