300+ TOP BLAZOR Interview Questions and Answer

Blazor Interview Questions for Freshers & Experienced Pdf Download

1. What is Blazor?
It’s a super awesome framework by Microsoft for building interactive client-side web UI with the best performance ever in .NET and C# named Blazor. In Blazor We use component-based architecture like other modern web development frameworks Angular or React.

2. Types of Blazor?
Microsoft is offering Blazor in 2 types, They are

  1. Blazor Server
  2. Blazor Web Assembly

3. What is Blazor Server?
Microsoft Blazor Server decouple the application layers as Blazor Components (in form of Razor component) with the support of C# to write the logic for the client browser. Blazor built on the top of the ASP.Net Core framework. It provides support for hosting Razor components on the server in an ASP.NET Core app. Blazor uses the SignalR for making a connection in the ASP.Net server to the DOM at Client Side.

4. What is Blazor Web Assembly (WASM)?
Microsoft Introduced Blazor WebAssembly as a new way to use ASP.NET core at the client-side. This is in preview edition till now (March 2020). Blazor WebAssembly is a nice and clean way to create a single-page app for building interactive client-side web apps with the power of C# on client-side too, means on the browser with the uses of open web standards without any plugins or code transpilation.

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

6. What are the Features of Blazor?
Blazor is much inspired by the other new and Morden UI Frameworks with many features. It’s not a replacement of any other JavaScript-based UI Frameworks, but yes it could be the best way for all the .Net Developer for creating next application with the list of rich features, as follows:

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

7. What is the component in Blazor?
Blazor uses the Razor template engine that generates HTML and serves to the web browsers. We can use both HTML and C# syntax all together in the Razor templates and Razor engine then compiles the Razor templates to generate the HTML. In Blazor Components we can use In-Line coding for the logics 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.

8. What are the Pros and Cons of Blazor Server?
Blazor Server Pros:

  • Page download size is very less.
  • Full support of .Net assemblies as you are using Dot Net core at the server.
  • Debugging like a boss.
  • Run-on any browser.
  • No need for JavaScript.
  • Much secure, Code will be on Server only.

Blazor Server Cons:

  • No Offline support always needs an active server.
  • High latency network for server interactions.
  • More resources are required for managing SignalR instances.

9. What are the Pros and Cons of Blazor WebAssembly?
Blazor WebAssembly Pros:

  1. Low latency Network
  2. No Need for JavaScript understandings for client-side interactions.
  3. Offline support.

Blazor WebAssembly Cons:

  1. Page download size is big.
  2. Browser dependency, Internet Explorer not supported.
  3. Limited support of .Net Assemblies.
  4. Debugging is not so good at the client-side.
  5. Not so secure, DLLs will be download at the browser.

10. What are the steps to create and run the Blazor Server App using CLI commands?
We can open the command prompt and type following command to create a Blazor server app using asp.net core CLI:

dotnet new blazorserver -o WebApplication1

cd WebApplication1

dotnet run

11. What are the steps to create and run the Blazor WebAssembly App using CLI commands?
We can open the command prompt and type following command to create a blazor WebAssembly app using asp.net core CLI:

dotnet new blazorwasm -o WebApplication1

cd WebApplication1

dotnet run

12. How to define a route in Blazor?
Using @page directive we can define a route for blazor components. Now, we can create a new Blazor Component and at the top of the HTML of this blazor component, add simply @page ‘path’, like this:

@page ‘/’

This is for the home page or for those requests there is no URL parameter after domain but suppose we want to open new component and URL must be like ‘https://domain/counter’ so just add like this:

@page ‘/counter’

13. Data Binding in Blazor.
Bindings are the main thing to interact with the data or control object like Textboxes, Selects, or Forms elements, and here in this war of being the best Web Development framework, Blazor giving the tough competition to other modern Web development frameworks. Blazor comes with the best way to use bindings with One-way, Two-way Data Binding, and with the rich behavior of event binding.

14. How to do Two-way Data Binding in Blazor?
Two-way data binding is the by directional data flow, means in this case the information flows in both directions, Source to Destination and Destination to Source at the same time like, we use the data variables of my component class(es) as a source and we need to get the value of this variable on the HTML UI to display some messages or edit them.

In Blazor we have @bind from razor to read the value of any Blazor component’s data variable. @bind gets the value from the ref and holds it when user changed the data and leaves the focus, it updates the original source element.

@code {
public string data { get; set; } = “Default Text”;
}

<input class=”form-control” @bind=”data” />

15. What is the Event-Binding in Blazor?
Event binding is nothing but a way to call a handler function written in C# on a specific event, like on button click, text change, enter, or leaving the focus from a DOM element.

<button @onclick=”@(()=>changeCity())”>Click</button>

16. What are the life cycle methods of Blazor Components.

The Blazor application provides different functions for specific tasks in the life cycle of Blazor components in the form of synchronous as well as asynchronous methods.

  • OnInitialized
  • OnInitializedAsync
  • OnParametersSet
  • OnParametersSetAsync
  • OnAfterRender
  • OnAfterRenderAsync
  • ShouldRender

17. When should I use Blazor Server?
Blazor allows us to create rich interactive UI to our .NET apps. For using Blazor Server there are many reasons:

  1. There is no need to rewrite existing app logic.
  2. when you want to offload work from the client to the server.
  3. Blazor Server apps require only a small download to establish the connection.
  4. It is a great solution for apps that need to run on low-powered devices.

18. When should I use Blazor WASM?
Blazor allows us to create rich interactive UI to our .NET apps. For using Blazor WebAssembly there are many reasons:

  • Blazor WebAssembly require Low latency Network
  • No Need for JavaScript understandings for client-side interactions.
  • Blazor WebAssembly apps allow Offline support.

18. What is difference between Blazor WebAssembly App (with Asp.Net Core Hosted) and Blazor Server App?
There are two hosting models: Server-Hosted, and Client-Hosted. The difference is whether the app is hosted in server, or in client.

Server-Hosted Model
Server hosted model means your app logic runs in the server (you can think of it similar to what Web Forms is), you click on a button, an “Ajax” call sends the request, the server receives the request, and sends back the updated page. However, here it uses SignalR not Ajax, which is a low level socket communication (read efficient). And instead of updating a whole page, it updates only the relevant parts (thus it is a single page application).

Client-Hosted Model
Client hosted model means your logic runs within the browser. Think of it as if your C# logic is converted into JavaScript, and it is embedded in the page. So the logic runs in the browser. This could be possible after the introduction of WebAssembly.

WebAssembly App (with Asp.Net Core Hosted)
This options means having Blazor to include ASP.NET Core runtime. This is because you can write an offline app (e.g. calculator app) that does not need any kind of connection to external services, making ASP.NET Core irrelevant. However, you might want to write an online app that accesses online DB, external APIs, do verification, etc. For these kind of apps, you will need an ASP.NET Core stack to support your app.

Blazor Questions and Answers Pdf Download

Leave a Reply

Your email address will not be published. Required fields are marked *