【问题标题】:Shortcut Microsoft Authentication快捷方式 Microsoft 身份验证
【发布时间】:2016-01-07 23:41:48
【问题描述】:

我们正在尝试使用 ASP.NET 5 Web 应用程序模板将 Microsoft 身份验证引入我们的应用程序。

默认模板将用户从_LoginPartial.cshtml 中的登录链接带到他们选择首选身份验证提供程序的登录页面。我们只想接受 Microsoft 身份验证,因此我们希望 _LoginPartial.cshtml 让用户登录。

我修改了_LoginPartial.cshtml

<ul class="nav navbar-nav navbar-right"> @*<li><a asp-controller="Account" asp-action="Register">Register</a></li>*@ <li><a asp-controller="Account" asp-action="ExternalLogin">Log in</a></li> </ul>

我也改了AccountController ExternalLogin的provider参数

        public IActionResult ExternalLogin(string provider="Microsoft", string returnUrl = null)
    {
        // Request a redirect to the external login provider.
        var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
        var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
        return new ChallengeResult(provider, properties);
    }

但在我的情况下,ExternalLogin 没有被调用并且是一个空白页

http://localhost:52711/Account/ExternalLogin 被返回。

我做错了什么?

【问题讨论】:

    标签: asp.net-core asp.net-core-mvc entity-framework-core asp.net-identity-3


    【解决方案1】:

    我通过用表单替换登录链接按钮解决了这个问题

        <form asp-controller="Account" asp-action="ExternalLogin" method="post" asp-route-returnurl="@ViewData["ReturnUrl"]" class="navbar-right">
        <button type="submit" class="btn btn-link navbar-btn navbar-link" name="provider" value="Microsoft" title="Log in">Log In</button>
    </form>
    

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 1970-01-01
      • 2022-08-23
      • 1970-01-01
      • 2019-04-22
      • 2017-09-20
      • 2017-11-26
      • 2021-03-31
      • 2020-05-14
      相关资源
      最近更新 更多