我们正在尝试使用 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>
我还更改了 provider 参数AccountController ExternalLogin
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
被退回。
我究竟做错了什么?