Share via

Launch multiple Blazor hosted WASMs from a single MVC app

JeffB 1 Reputation point
2021-12-02T20:36:20.82+00:00

We are working on a government-based project on which it takes a lot of paperwork just to open a single public-facing URL.

The organization wants to create a new SINGLE public-facing website (ASP.NET Core MVC app, with Web API endpoints) which will need to contain various context-specific sub-applications. We would like to have each sub-application to be it's own Blazor hosted WASM project. All of these will communicate with the same web API endpoints on the public-facing site.

Basically we want to create an MVC app (.NET Core) which will provide links for deploying multiple Blazor WASMs from it.

After much searching, I haven't seen any examples of how to do this. The closest I've seen is this:
https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#hosted-deployment-with-multiple-blazor-webassembly-apps
However in this example, it has each Blazor app use a different port #. This won't work for us.

Advice? Doable? Bad idea??

Developer technologies | .NET | Blazor
0 comments No comments

2 answers

Sort by: Most helpful
  1. Michael Washington 921 Reputation points MVP
    2021-12-02T21:57:30.067+00:00

    Oqtane will allow you to achieve this: https://github.com/oqtane/oqtane.framework

    154612-image.png

    Was this answer helpful?

    0 comments No comments

  2. Bruce (SqlWork.com) 84,086 Reputation points
    2021-12-02T21:17:11.317+00:00

    the browser limits you to one WASM loaded per website. generally blazor WASM are hosted by a static website, so you just need one static site with folders per sub application. the browser will see the each folder as its own site.

    /app1/<blazor site>
    /app2/<blazor site>

    when you publish the blazor sites you need to set the base path as explained in the article you referenced. port numbers are fine for development.

    note: an asp.net core site could host all the blazor sites in wwwroot. this would just be a deploy step.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.