Blazor - C# In Browser

We all know how web applications work. Mainly a web application consists of a server and a client. Server side web app connects to databases and other third party services. while client side app connects with the server side app.
 
Most of the server side web apps are developed using DotNet, Java, Python, Php and many more.
 
And there are many Javascript frameworks available like Angular, React, Vue and many more for client side app development.
 
Blazor - C# In Browser
 
This is fine, but it does mean that there is a fundamental disconnect. You can't use the language that you use for your server-side code to create UIs for the browser. So you can't reuse your skillset, and some of these UI frameworks have a pretty steep learning curve. Wouldn't it be great if you could use the same language on your server, in your libraries, and in the UI?
 
For Javascript developers, the server side development can be done using NodeJS. In this case, both client and server are developed using javascript.
 
Being a C# developer, I have dreamt of using C# for client side development so that I can make use of my existing skills.
 
I am so excited to say that Microsoft has launched a framework named BLAZOR.
 
Blazor is a framework which helps us to develop client side apps in C#. In simple words, Blazor is C# + HTML running in the browser.
 
In my upcoming articles, I shall explain more on Blazor development. Here let us focus on the theoretical knowledge.
 
There are 2 flavors of Blazor.
  • Blazor WebAssembly
  • Blazor Server

Blazor WebAssembly

 
Blazor WebAssembly includes a proper .NET runtime implemented in WebAssembly, a standardized byte code for the web. This .NET runtime is downloaded with your Blazor WebAssembly app and enables running normal .NET code directly in the browser. Blazor runs in all modern web browsers, desktop and mobile apps.
 
Benefits
  • Near-Native performance.
  • Can work offline.
  • No server needed.
    • Technology to serve static files.
  • Use client side resources.
  • Runs in all modern web browsers.
Downsides
  • Restricted to capabilities of browser - Works only on modern web browsers.
  • Browser does all the heavy lifting.
  • App loading takes time - Basically .Net code is compiled and loaded in the browser.
  • Web Assembly is required.

Blazor Server

 
Blazor can run client logic on the server. Client UI events are sent back to the server using SignalR - a real-time messaging framework. Once execution completes, the required UI changes are sent to the client and merged into the DOM.
 
Benefits
  • Small downloads, loads fast -> All client side logic is running on the server.
  • Access to full ASP.NET framework.
  • Web Assembly not required.
Downsides
  • No offline support - As all client side logic runs on server, there is no offline support.
  • Need a server running ASP.NET core.
  • Higher latency & slower application.
Blazor - C# In Browser

Summary

 
This article talks about Blazor and its various flavors.