Open Closed

Loading all application after logout - Blazor WASM #4967


User avatar
0
Leonardo.Willrich created

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v7.0.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular):

We have migrated an application Blazor WASM from version 4.4 to 7.0.1. I have noticed that when the user logs out, it is redirecting to the host application and then redirecting to the login page, forcing it to load all modules again. It is taking time and is annoying. In the previous version, it was redirected to the authentication page right away.

Here are the customizations done as per this topic: https://support.abp.io/QA/Questions/1152/How-to-to-Login-page-when-accessing-the-app-and-after-logout

Is possible to improve it somehow?


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    As you know, This is a limitation of Blazor WebAssembly.

    Recently I noticed an issue: https://github.com/dotnet/aspnetcore/issues/31926 But Microsoft doesn't think it's a problem, I'll try it anyway if it improves performance.

    In the previous version, it was redirected to the authentication page right away.

    I think this solution still works

    https://support.abp.io/QA/Questions/1152/How-to-to-Login-page-when-accessing-the-app-and-after-logout#answer-d2e834e0-4600-d3d0-eb47-39fbdb7edfc7

  • User Avatar
    0
    Leonardo.Willrich created

    Sorry liangshiwei, but, I have to disagree. In this case, I don't see it as a Blazor WebAssembly limitation. The previous version worked differently. When logging out, it was been redirected straightaway to the authentication page. Now, it is going to the host side by calling connect/logout and then it gets redirected to the authentication page. It provokes reloading the application again, annoying the users. Could explain why it is a limitation in this latest version? Maybe I'm missing some point.

    Is there a way to avoid the connect/logout?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Actually, I mean slow loading performance is a limitation of Blazor.

    Which Authserver are you using? identityserver or openididct.

  • User Avatar
    0
    Leonardo.Willrich created

    Hi, My project is very similar to a fresh new template. I'm using OpenIdict. You can download a new template using EF and Blazor WASM, just log in and logout, you will see it goes to the host and then goes to Blazor and finally is redirected to the host login page again.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try this:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LogoutController))]
    public class MyLogoutController : LogoutController
    {
        [HttpGet]
        public async override Task<IActionResult> GetAsync()
        {
            await SignInManager.SignOutAsync();
    
            var blazorUrl = "https://localhost:44307"; // front-end url
            var postLogoutRedirectUri = string.Empty;
    
            if (HttpContext.Request.Query.ContainsKey("post_logout_redirect_uri"))
            {
                postLogoutRedirectUri = HttpContext.Request.Query["post_logout_redirect_uri"].ToString();
            }
            
            
            if (postLogoutRedirectUri.StartsWith(blazorUrl))
            {
                return Redirect($"https://localhost:44305/account/login?returnUrl={blazorUrl}");
            }
            
            return SignOut(authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
        }
    }
    
  • User Avatar
    0
    Leonardo.Willrich created

    Excellent, it worked like a charm! As a suggestion, it would be the default implementation for the framework.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15