What is Blazor?

Blazor is a framework developed by Microsoft that allows developers to build interactive web UI applications using C# and .NET instead of HTML, CSS, and JavaScript. The name "Blazor" is formed through two words: Browser and Razor.

 

Blazor offers different hosting models: Blazor WebAssembly, Blazor Server Side, and Hybrid model (Blazor WebAssembly + Server side).

 

Blazor WebAssembly: C# code runs on the browser directly using WebAssembly (Wasm) through this hosting model. WebAssembly or Wasm is a binary instruction format which enables running code written in multiple languages on the browser. Blazor WebAssembly project should make HTTP calls to access the resources like the database on the server.

 

Blazor Server Side: TheBlazor Server project runs on the server. That means it will have full access to the server resources. Blazor Server project uses SignalR to interact with web browsers. It must keep a live SignalR connection for each browser session to track the current state of each browser session. Even though the Blazor Server project is more secure because it needs to maintain a live connection with the browser, it is unsuitable for projects where we need to support many clients.

 

Blazor Hybrid: Using this project, UI renders to a web view control using a local interop channel hosted in a .NET MAUI app.

 

With the .Net 8 release, we have more hosting models available in Blazor, like Server-Side rendering, Streaming rendering, Interactive WebAssembly rendering, Interactive Server rendering, and Interactive automatic rendering. We will discuss each of these hosting models in our future articles.