You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure B2C自定义策略生产环境登出请求被取消问题求助

Azure B2C自定义策略生产环境登出请求被取消问题排查求助

生产环境部署的Azure WebApp执行登出操作时,以下请求URL被取消:
https://cargonew.b2clogin.com/cargonew.onmicrosoft.com/b2c_1a_signup_signin/oauth2/v2.0/logout?post_logout_redirect_uri=https%3A%2F%2Fw-identity.azurewebsites.net%2Fsignout-callback-oidc-b2c
该功能在开发环境可正常使用。

登出取消截图:Logout Cancelled Screenshot

已完成的配置操作:

  • 已在B2C应用注册中配置CORS策略及所有回复URL
  • 尝试将以下URL设置为前端通道登出URL:
    • https://cargonew.b2clogin.com/cargonew.onmicrosoft.com/b2c_1a_signup_signin/oauth2/v2.0/logout
    • https://w-identity.azurewebsites.net/Account/SignOut
    • https://w-identity.azurewebsites.net/signout-callback-oidc-b2c

技术栈说明:

  • 前端采用Angular框架
  • 所有身份认证交互由ASP.NET Core Identity Server处理
  • 使用用户流时,登出功能运行正常

相关代码片段

C#代码

[HttpGet]
public async Task<IActionResult> Logout(string logoutId, string type)
{
    var logout = await _interaction.GetLogoutContextAsync(logoutId);
    return await (logout.Parameters[LOGIN_TYPE_PARAM_NAME] != INTERNAL_USER ? SignOut(logoutId) : InternalSignOut(logoutId));
}

[HttpGet]
public async Task<IActionResult> SignOut(string logoutId)
{
    ClearUserRoleSwitchData();

    // sign out local identity server
    await HttpContext.SignOutAsync();

    // sign out B2C
    var callbackUrl = Url.Action(nameof(SignedOut), "Account", new { logoutId = logoutId }, protocol: Request.Scheme);
    return SignOut(new AuthenticationProperties { RedirectUri = callbackUrl },
        CookieAuthenticationDefaults.AuthenticationScheme, "B2C");
}
[HttpGet]
public async Task<IActionResult> SignedOut(string logoutId)
{
    if (User.Identity.IsAuthenticated)
    {
        // Redirect to home page if the user is authenticated.
        return RedirectToAction(nameof(HomeController.Index), "Home");
    }

    var logout = await _interaction.GetLogoutContextAsync(logoutId);

    if (!string.IsNullOrWhiteSpace(logout?.PostLogoutRedirectUri))
    {
        return Redirect(logout?.PostLogoutRedirectUri);
    }

    return View();
}

配置JSON

"AzureAdB2C": {
  "ClientId": "6db9a5f0-e2a3-4f16-a738-1479bc71ef5b",
  "Tenant": "cargonew",
  "SignUpSignInPolicyId": "B2C_1A_SIGNUP_SIGNIN",
  "ResetPasswordPolicyId": "B2C_1A_PASSWORDRESET",
  "EditProfilePolicyId": "",
  "CallbackPath": "/signin-oidc-b2c",
  "SignedOutCallbackPath": "/signout-callback-oidc-b2c",
  "SignedOutRedirectUri": "https://w-app.azurewebsites.net/login"
}

现需排查并解决生产环境中Azure B2C自定义策略登出请求被取消的问题。

内容的提问来源于stack exchange,提问作者Ayush Raj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 04:12:07