What is Blazor (An Overview)
In this article, I am going to discuss What is Blazor. Microsoft has recently released a new .NET web framework called Blazor. It is a free, open-source Web framework to build Web apps using C# that run in a Web browser. As part of this article, I am going to discuss the following pointers in detail.
- How we develop web applications today?
- What is Blazor?
- Why should we use it?
- Understanding WebAssembly
- What are the advantages of using Blazor?
How we develop web applications today?
In order to become a full-stack software developer and to stay in the market, you need to learn a client-side programming language (Angular, React, Vue, etc.) as well as a server-side programming language (C#, Java, PHP, etc.). Now the question is, why should we learn 2 different sets of programming languages and frameworks.
Can we use C# both for server-side and client-side development?
How can a browser execute C# code?
What is WebAssembly?
ASP.NET Core Blazor Hosting Models
The Blazor offers 2 hosting models. Blazor WebAssembly and Blazor Server.
This is also called the client-side hosting model and in this hosting model, the Blazor application going to be run directly in the browser. So, everything the application needs i.e the compilation of application code, its dependencies, and the .NET runtime are downloaded to the browser. In our upcoming articles, we will discuss Blazor WebAssembly in detail in our Blazor Hosting Models article.
This is also called the server hosting model and in this hosting model, the application is executed on the server from within an ASP.NET Core application. Between the client and the server, a SignalR connection is established. When an event occurs on the client such as a button click, 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 back again to the client, it’s only the difference that is sent to the client over the established SignalR connection. The browser then updates the UI. It embraces the single page application architecture which rewrites the same page dynamically in response to the user action. Since only the diff is applied to update the UI, the application feels faster and more responsive to the user. In our upcoming articles, we will discuss more Blazor Server.
The ASP.NET Blazor makes web development easier and more productive by providing a full-stack web development with .NET Framework. Following are the advantages of using Blazor.
- .NET offers a range of APIs and tools across all platforms that are stable and easy to use.
- Modern languages such as C# and F# offer a lot of features that make programming easier and interesting for developers.
- The availability of one of the best IDE in form of Visual Studio provides a great .NET development experience across multiple platforms such as Windows, Linux, and macOS.
- .NET provides features such as speed, performance, security, scalability, and reliability in web development that make full-stack development easier.
- Blazor also supports features of a SPA (Single Page Application) framework such as:
- Dependency Injection
- Forms and validation
- Server-side rendering
Where can we use Blazor?
We can use Blazor WebAssembly in any web browser that supports WebAssembly. Nowadays, any modern browser supports web assembly. So, in most of the cases, you should not have any problem. However, it is good to verify the web assembly supports by the browser in your preferred search engines and see whether the web browser supports the web assembly or not. As of this article, the following browsers support web assembly.
- IOS Safari
- Opera Mini
- Android Browser
- Blackberry Browser
- Opera Mobile
- Chrome for Android
- Firefox for Android
- IE Mobile
- UC Browser for Android
- Samsung Internet
As you can see most of the browser supports web assembly. However, sometimes we need to support all the browsers such as Internet Explorer. In this case, you can not use Blazor on the client-side. As per the official Microsoft Documentation, only Internet Explorer 11 is to be supported by Blazor on the server-side.
Note: The point that you need to remember is, if you want to support only the modern web browser, then use Blazor. On the other hand, if you want to support browsers such as Microsoft Internet Explorer, then it is probably not advisable to use Blazor.
In the next article, I am going to discuss the Environment Setup for Blazor App Development. Here, in this article, I try to give an overview of Blazor. I hope you enjoy this article.
About the Author: Pranaya Rout
Pranaya Rout has published more than 3,000 articles in his 11-year career. Pranaya Rout has very good experience with Microsoft Technologies, Including C#, VB, ASP.NET MVC, ASP.NET Web API, EF, EF Core, ADO.NET, LINQ, SQL Server, MYSQL, Oracle, ASP.NET Core, Cloud Computing, Microservices, Design Patterns and still learning new technologies.