小编Lae*_*nde的帖子

外部注销后如何重定向到设置注销页面(openid Connect)Asp net core 3.1

我正在尝试使用 OpenId Connect (oidc) 作为登录提供者为网页(asp net core 3.1)实现外部登录/注销。登录工作正常,但注销重定向未按预期工作。我确信有一个简单的修复方法,但我对 .NET 开发还很陌生。这是我迄今为止尝试过但没有成功的方法:

注销的 HTML 如下所示:

<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout">
    <button type="submit" class="nav-link btn btn-link text-light">Logg ut</button>
</form>
Run Code Online (Sandbox Code Playgroud)

Logout.cshtml.cs:

        //public async Task<IActionResult> OnPost(string returnUrl = null)
        //{
        //    await _signInManager.SignOutAsync();
        //    await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
        //    await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme);
        //    _logger.LogInformation("User logged out.");
        //    if (returnUrl != null)
        //    {
        //        return LocalRedirect(returnUrl);
        //    }
        //    else
        //    {
        //        return RedirectToPage();
        //    }

        //}

        public async Task<IActionResult> OnPost()
        {
            var user = HttpContext.User;
            if (user?.Identity.IsAuthenticated …
Run Code Online (Sandbox Code Playgroud)

c# asp.net openid-connect asp.net-core

5
推荐指数
2
解决办法
785
查看次数

标签 统计

asp.net ×1

asp.net-core ×1

c# ×1

openid-connect ×1