Starts in:
2 DAYS
5 HRS
3 MIN
48 SEC
Starts in:
2 D
5 H
3 M
48 S
Open Closed

Hosting Multiple Blazor WebAssembly Applications #6277


User avatar
0
Spospisil created
  • ABP Framework version: v7.3.0
  • UI Type: Blazor WASM
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

Hi,

Do you have example of how to configure the ABP public website generated from abp suite so that it can host multiple Blazor WebAssembly applications that correctly with the LeptonX theme and all the necessary files to render the theme correctly? We use something like the following code block to setup the ability to host one or more Blazor WebAssembly applications in the xxxxxxWebPublicModule.cs class

Thanks.

    app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/Blazor"), app1 =>
    {
        //app1.Use((ctx, nxt) =>
        //{
        //    ctx.Request.Path = "/Blazor" + ctx.Request.Path;
        //    return nxt();
        //});

        app1.UseBlazorFrameworkFiles("/Blazor");
        app1.UseStaticFiles("/Blazor");
        app1.UseStaticFiles();
        app1.UseRouting();
        app1.UseAuthentication();
        if (MultiTenancyConsts.IsEnabled)
        {
            app1.UseMultiTenancy();
        }
        app1.UseAuthorization();
        app1.UseDevExpressControls();
        app1.UseWebAssemblyDebugging();
        app1.UseEndpoints(endpoints =>
        {
            endpoints.MapFallbackToFile("/Blazor/{*path:nonfile}", "/Blazor/index.html");
        });
    });

Thanks.


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

    Hi,

    No, we don't have such an example and I don't recommend you use wasm as a public website. wasm often takes longer to load.

  • User Avatar
    0
    Spospisil created

    Hi,

    I didn't say I was using WASM as the public website. I said I was using the public website as the host for 1 or more WASM applications, much in the way that ABP's examples show the AuthServer project being used in the same manner. So what's the difference between using the public site vs the auth server as the host for a wasm application?

    What do you recommend as the host for one or more WASM applications using the ABP framework?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    much in the way that ABP's examples show the AuthServer project being used in the same manner

    Are you talking about this? https://community.abp.io/posts/blazor-webassembly-asp.net-core-hosted-zbjvgrc9

    What do you recommend as the host for one or more WASM applications using the ABP framework?

    I think this is no different from the standard ASPNETCore application.

    If you face any problems you can share a test project with me and I will check it. thanks. shiwei.liang@volosoft.com

  • User Avatar
    0
    Spospisil created

    much in the way that ABP's examples show the AuthServer project being used in the same manner

    Are you talking about this? https://community.abp.io/posts/blazor-webassembly-asp.net-core-hosted-zbjvgrc9

    Yes, I am talking about this example.

    What do you recommend as the host for one or more WASM applications using the ABP framework?

    I think this is no different from the standard ASPNETCore application.

    So, whether it's the public site (built from ABP suite) or the AuthServer project, both could serve as a 'host' for one or more blazor WASM applications?

    If you face any problems you can share a test project with me and I will check it. thanks. shiwei.liang@volosoft.com

    I will get an example project for you tomorrow to show you essentially what we're trying to do technically to supplement what I've already explained.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    So, whether it's the public site (built from ABP suite) or the AuthServer project, both could serve as a 'host' for one or more blazor WASM applications?

    I'm not sure. If a standard ASPNETCore application(without ABP) can do it, then ABP also can do it.

    I will get an example project for you tomorrow to show you essentially what we're trying to do technically to supplement what I've already explained.

    Ok.

  • User Avatar
    0
    Spospisil created

    Hi,

    I've just given you access to a github repository that shows the public site hosting the blazor wasm app. For some reason I can't get it to even work at the moment, but take a look at the solution to visually see what I am attempting to accomplish.

    Thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I added some changes to make it work, you can check my commit: https://github.com/spospisil/TestTheme/commit/09dfcc0ba8d64116aefb85807d40093d58d0b27a

  • User Avatar
    0
    Spospisil created

    Hi,

    Although the site now renders, I get an error when I click the 'login' button from https://localhost:44359/Blazor and if you choose the 'salesdemo' theme from the right menu it does not change the elements associated the btn-primary to red as defined in my salesdmo.css file but I also get an error in the browser saying it 'refused to apply style from'..... See screenshots below. I've committed my version of the source so you can reproduce.

    I've resolved this error by just putting a /blazor in the a link of the Index.razor file (<a href="/Blazor/authentication/login" class="btn btn-primary mb-1">)

  • User Avatar
    0
    Spospisil created

    Hi,

    Running abp bundle in the Blazor project folder fixed this remaining issue. Thank you for your help on both these issues.

    Steve

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    : )

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06