Web apps - Blazor - Hosting models

In this article

Blazor Server

Blazor Server is a server-side Java app development platform.

In a traditional server-rendered app, opening the same app in multiple browser screens (tabs or iframes) typically doesn't translate into additional resource demands on the server. For the Blazor Server hosting model, each browser screen requires a separate circuit and separate instances of server-managed component state. Blazor considers closing a browser tab or navigating to an external URL a graceful termination. In the event of a graceful termination, the circuit and associated resources are immediately released. A client may also disconnect non-gracefully, for instance due to a network interruption. Blazor Server stores disconnected circuits for a configurable interval to allow the client to reconnect.

The browser interacts with Blazor (hosted inside of an ASP.NET Core app) on the server over a SignalR connection.!

On the client, the Blazor script establishes the SignalR connection with the server. The script is served from an embedded resource in the ASP.NET Core shared framework.

The Blazor Server hosting model offers several benefits:

The Blazor Server hosting model has the following limitations:

Blazor Server apps are hosted on Azure.

Blazor WebAssembly

The Blazor WebAssembly hosting model runs components client-side in the browser on a WebAssembly-based .NET runtime. The Blazor WebAssembly hosting model runs components client-side in the browser on a WebAssembly-based .NET runtime.

Blazor WebAssembly: Blazor runs on a UI thread inside the browser.!

Blazor WebAssembly is a full-stack .NET web development tool that allows you to build web apps using a single codebase.

The Blazor script handles:

WebAssembly from Blazor reduces the download times of large apps by up to 50%.

The Blazor WebAssembly hosting model offers several benefits:

The Blazor WebAssembly hosting model has the following limitations:

Blazor Hybrid

Hybrid apps with .NET and Blazor render UI in a Web View control, where the HTML DOM interacts with Blazor and .NET of the native desktop or mobile app.!

Which Blazor hosting model should I choose?

Feature Blazor Server Blazor WebAssembly (WASM) Blazor Hybrid
Complete .NET API compatibility Supported Not supported Supported
Direct access to server and network resources Supported Not supported Not supported
Small payload size with fast initial load time Supported Not supported Not supported
Near native execution speed Supported Supported Supported
App code secure and private on the server Supported Not supported Not supported
Run apps offline once downloaded Not supported Supported Supported
Static site hosting Not supported Supported Not supported
Offloads processing to clients Not supported Supported Supported
Full access to native client capabilities Not supported Not supported Supported
Web-based deployment Supported Supported Not supported

After you choose the app's hosting model, you can generate a Blazor Server or Blazor WebAssembly app from a Blazor project template. For more information, see Tooling for ASP.NET Core Blazor.

Complete .NET API compatibility

Direct access to server and network resources

Small payload size with fast initial load time

Near native execution speed

App code secure and private on the server

Run apps offline once downloaded

Static site hosting

Blazor WebAssembly apps can be hosted on the Blazor web server.

Offloads processing to clients

Full access to native client capabilities

Web-based deployment

Blazor web apps are updated on the next app refresh from the browser.

Setting a component's hosting model

Ref: ASP.NET Core Blazor hosting models