.NET › Blazor (Server & WebAssembly)

What is Blazor, and what are the two primary hosting models (Server and WebAssembly)?

Beginner

Answer

Blazor is a framework for building interactive web UIs using C# and .NET instead of JavaScript. Blazor Server runs application logic on the server, with the browser maintaining a persistent SignalR connection that relays UI events up and DOM updates down as lightweight diffs. Blazor WebAssembly (WASM) instead downloads the .NET runtime and app assemblies to the browser, executing entirely client-side, with no ongoing server connection required for UI logic.
// Program.cs for Blazor Server
builder.Services.AddRazorComponents().AddInteractiveServerComponents();

// Program.cs for Blazor WebAssembly (client project)
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
Real-world example An internal admin tool with users on a reliable corporate network chooses Blazor Server for its fast initial load and simpler debugging, while a public-facing app needing offline capability chooses Blazor WebAssembly instead.

Common follow-ups: What is Blazor United / Auto render mode and how does it combine both models?;What are the latency implications of Blazor Server's SignalR dependency?