Blazor Server side vs Blazor WebAssembly Hosted

Newbie Dev 156 Reputation points
2022-02-25T11:27:59.06+00:00

I am new to blazor and trying to understand the differences between different hosting models.

From what I read I understand Blazor Server side and Blazor WebAssembly Hosted have server side code, both uses Signal R to communicate with the Client.

So what is the difference between them? Where is the client side of theses deployed to? What difference is in their connection with Server? If the Web App inturn calls a 3rd party web API how is the call routed?

One difference I found was in the project structure. Blazor Server side has only one project (with a Data Folder). Blazor WebAssembly Hosted has 3 projects(.Server, .Client and .Shared).

Developer technologies .NET Blazor
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-02-25T17:03:31.643+00:00

    blazor is two components

    a javascript engine that sends events to blazor, and manages updates to the dom. via javascript interop, it can execute javascript commands sent by the blazor engine

    the blazor component engine that send html updates to javascript engine.

    blazor server:
    if blazor is hosted on the server, the javascript engine opens signal/r connection to the server which hosts the blazor engine. all communication is over the signal/r connection. the blazor engine has all the state.

    The blazor code has full access to server services, and .net libraries.

    blazor client:
    the blazor code is compiled to WASM. the javascript engine is responsible for loading the blazor code, which is just a url. the javascript and blazor communicate over the browser messaging services. no signal/r is required. actually no server code is required at all, it can be a static site.

    if the blazor client needs to call a server, it can use any method supported by the javascript, as WASM is a sandbox with no network access. HttpClient for example uses javascript interop to make network calls.

    Because of the sandbox, and the reduced services of the blazor WASM runtime support, many nuget packages will not work with blazor client.

    when creating a blazor wasm project you have two options:

    1) standalone static blazor site
    2) a blazor static site and webapi project to host the blazor static site. the blazor code would use httpclient to call the webapi server.

    1 person found this answer helpful.
    0 comments No comments

  2. AlexChow 11 Reputation points MVP
    2022-12-07T21:01:53.027+00:00

    A lot has been said before, and I will add it based on my experience:

    1. ssr : is conducive to quick response and debugging, and it is very convenient to develop without writing the controller.
    2. wasm : the first startup of deployment is very slow, and debugging greatly affects efficiency.
    1 person found this answer helpful.
    0 comments No comments

  3. AgaveJoe 30,126 Reputation points
    2022-02-25T16:20:35.107+00:00

    The difference between Blazor WASM and Blazor server is well documented.

    Blazor Server
    Blazor WebAssembly

    A hosted Blazor WASM project is just a way to host Blazor WASM (client) in a ASP.NET Core Web Application. If you look at the server project reference you'll see it references the client application. If you take a look at the fallback route, it returns index,.htm which is the Blazor WASM application.

    https://stackoverflow.com/questions/58093386/whats-the-difference-between-asp-net-core-hosted-and-server-side-blazor-really


Your answer

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