Our blogs
Practical insights from our engineers
What is Blazor?
19/20/2020

In this article, we will understand what Blazor is, but before that, let's first understand how web applications are developed today.

How are web applications developed today?

  • We use two completely different sets of programming languages.
  • For server-side development, we use programming languages like C#, Java, PHP etc.
  • For the client-side development we use JavaScript frameworks like Angular, React, Vue etc. There’s no doubt these JavaScript frameworks dominated client-side web development up until recently.
  • But the question is, why should we learn and use two completely different sets of programming languages and frameworks.

Can we use C# for both server-side and client-side web development?

Well, we can, and that's exactly why we use Blazor. With Blazor, we can now build interactive web UIs using C# instead of JavaScript. Blazor apps are composed of reusable web UI components implemented using C#, HTML, and CSS. Both client and server code are written in C#, allowing you to share code and libraries. Blazor is a feature of ASP.NET, the popular web development framework that extends the . NET developer platform with tools and libraries for building web apps.

How can a web browser execute C# code?

Browsers understand and execute only JavaScript. How is C# code executed in the client browser? Well, the answer is WebAssembly (which is commonly called WASM in short)

Blazor can run C# code directly in the browser, using WebAssembly. It runs in the same security sandbox as JavaScript frameworks like Angular, React, Vue etc. Not just C#, in fact, we can run any type of code in the browser using WebAssembly.

WebAssembly is based on open web standards. So, it is a native part of all modern browsers including mobile browsers. This means for the Blazor application to work, there is no need to recompile C# code into another language or install any special plugins like back in the days of silver light and flash.

What is Blazor?

Just like many of the client-side development frameworks like Angular and React for example, Blazor is also a single page application framework i.e. SPA framework in short. We use Blazor for building interactive client-side web apps with C# and .NET instead of JavaScript. This means we can now leverage the existing ecosystem of . NET libraries even for the client-side web development.

  • When we build a Blazor WebAssembly Project and run it in a browser
  • Our project source code i.e., C# and Razor code files are compiled into .NET assemblies.
  • These compiled assemblies, any dependencies they may have and the .NET runtime are downloaded to the client browser.
  • Blazor WebAssembly then bootstraps the .NET runtime and loads the assemblies for execution.

Blazor WebAssembly and Blazor Server

Lot of people have a confusion if Blazor WebAssembly and Blazor Server are two different frameworks. They are not, we have only one Blazor framework. Blazor WebAssembly and Blazor Server are just 2 different hosting options. As the names imply, Blazor Server project runs on the server and Blazor WebAssembly runs on the client-side in the browser.

Blazor WebAssembly Server Communication

Deepening on how we developed our Blazor WebAssembly app, it can either run entirely on the client in isolation without a connection to the server or interact with the server only when server-side data is required.

For example, an application like a calculator doesn't require any server-side data. After the app and its dependencies are downloaded on to the client browser, the connection with the server can be safely terminated and the app can function completely offline in the client browser.

We can also have a Blazor WebAssembly app, that for the most part works offline without a connection to the server. Only when it requires server-side data like customer data, it interacts with the server using web API calls or SignalR. This is very similar to how Angular or React applications work.

Blazor WebAssembly Prerequisites

  • C#
  • HTML
  • CSS

Blazor is a great technology for .NET developers.

Hello MAUI!

8/7/2021

MAUI is the next evolution of Xamarin.Forms,Which is built on 6 Or 7 years Xamarin Forms experience,

What is Blazor?

8/7/2021

In this article, we will understand what Blazor is, but before that, let's first understand how web applications are developed today

Introducing FlutterFlow

8/7/2021

Building Flutter apps is now faster than ever with FlutterFlow!

Next.js, an awesome piece of technology

11/7/2021

Next.js is a react framework, which It means It’s a platform for developing single page application using react , it makes the wesite faster and high performance

Ready to raise the difficulty level?

Let's Talk

Call for query+1Show Number+971Show NumberMail us for help!Show EmailDubai, United Arab EmiratesToronto, CanadaOur offices