Interview Questions in Blazor

What is Blazor?

Blazor is a free, open-source, cross-platform Web framework that allows developers to build modern, scalable, and cross-platform Web applications using C# and .NET.
Blazor developed by Microsoft and the open-source community is initially designed to keep in mind C# and .NET developers who want to build web client applications using C# language.

Blazor framework allows developers to create rich interactive UIs using C# instead of JavaScript.

Blazor supports both client-side and server-side coding. Both server-side and client-side app logic is written in .NET.

Even though the code is written in .NET and C#, Blazor renders the UI as HTML and CSS for wide browser support, including mobile browsers.

What are the different flavors of Blazor? (What are the different types of Blazor ?)

Microsoft is offering Blazor in two types, as:

Blazor Server
Blazor Web Assembly

The above two categories are defined based on the hosting models.

What is Blazor Server?

It is a server which is built on top of the ASP.Net Core framework. It  supports the hosting of the Razor components on the server in an ASP.NET Core app. It uses the SignalR connection for making a connection between the ASP.Net server to the DOM on the Client Side.

What is Blazor Server hosting model?

With this hosting model, the application is executed on the server. Between the client and the server, a SignalR connection is established. When an event occurs on the client such as a button click for example, the information about the event is sent to the server over the SignalR connection. The server handles the event and for the generated HTML a diff (difference) is calculated. The entire HTML is not sent again to the client, it’s only the diff that is sent to the client over the SignalR connection. The browser then updates the UI. Since only the diff is applied to update the UI, the application feels faster and more responsive to the user.

What is Blazor Web Assembly (WASM)?

It’s a WebAssembly using which the Blazor application can run directly in the web browser. So, everything the application needs i.e the compiled application, its dependencies, and the .NET runtime are downloaded to the client browser from the server. A Blazor WebAssembly app can run entirely on the client without a connection to the server or we can optionally configure it to interact with the server using web API calls or SignalR.

Note: According to “”: WebAssembly (abbreviated WASM) is a binary instruction format for a stack-based virtual machine. WASM is designed as a portable target for the compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.

What are the Features of Blazor?

  • Component-based architecture
  • DI (Dependency Injection
  • Blazor Forms and Validation
  • Live Reload
  • JavaScript interop
  • Unit Testing.

What is the component in Blazor?

Blazor uses the Razor template engine that generates HTML and serves web browsers. We can use both HTML and C# syntax all together in the Razor templates and the Razor engine then compiles the Razor templates to generate the HTML. In Blazor Components we can use In-Line coding for the logic or we can separate it and can write the component functions into a separate C# class file. We use @code {} block for writing the C# functions along with HTML.

Blazor uses the “. razor” extension for Component identification.

What are the differences between Blazor Server and Blazor WASM?

Blazor WebAssembly
Server-side Blazor