OWIN挑战方法不执行任何操作

问题描述 投票:-1回答:1

我正在尝试将Microsoft帐户登录信息集成到我的ASP.NET MVC应用程序中,并且具有此控制器方法:

public void SignIn()
{
    // HACK - we will be signed into only one account if we are not signed in to MS
    if (Request.GetOwinContext().Authentication.User.Identities.Count() <= 1)
    {
        // Signal OWIN to send an authorization request to Azure
        Request.GetOwinContext().Authentication.Challenge(
            new AuthenticationProperties { RedirectUri = "http://localhost:31503/MicrosoftCalendar" },
            OpenIdConnectAuthenticationDefaults.AuthenticationType);
    }
}

我期望发生的是,系统提示我登录我的Microsoft帐户;取而代之的是,此方法一遍又一遍地运行,什么也不做,直到我的浏览器出现“重定向过多”错误。如何获得Challenge方法实际执行的操作?

我的网络项目中有一个班级OwinStartup;我将其设置为像这样的OWIN启动类:

[assembly: OwinStartup(typeof(Root.OwinStartup))]

但是出于某种原因,我在该启动类中的断点从未受到攻击; OWIN从未被初始化...实际上,等待一秒钟,它正在被初始化,但是诸如OnAuthorizationCodeReceivedAsync之类的事件处理程序却从未被点击...

如果我单步执行代码,在Challenge方法中调用SignIn后,由于某种原因,我将重定向到UserController,这又将我重定向到SignIn方法。我想知道为什么我要进入UserController吗?

c# asp.net-mvc owin
1个回答
0
投票

我无法发表评论,因为我没有足够的声誉,但是请尝试在您的RedirectUri后面加上斜杠>

添加更多:

尝试将您的呼叫更改为此:

© www.soinside.com 2019 - 2024. All rights reserved.