When you read about features in the new version of .NET Core, didn’t you think it was ever there before? Microsoft has already tried to move the WPF application into the browser and created Silverlight. It was quite an interesting solution for those times, but it is definitely the past. Later, something like ASP.NET WebForms appeared. Main building blocks of pages there are server controls. In the case of this solution, applications were slow, mainly due to the transfer of very large amounts of data.
However, Microsoft decided to try again and make that a fluent programmer in C# does not need to use other languages to create a web application. The perfect moment for this was the new technology, that is previously mentioned ASP.NET Core. It was then that the new framework, Blazor, was presented. Blazor is a mechanism that allows building web applications using C#, ASP.NET Core and Razor. There are two versions that can be distinguished in it: Blazor WebAssembly and Blazor Server.
This version was realized in the second part of 2019. In short, the application is hosted on the ASP.NET Core server and the changes rendered by the client go back to the browser over the network and then sent back to the client using SignalR, as shown in the scheme below. SignalR is a library that allows real-time transfer content between the clients and the server.
First project using Blazor
First, you must have installed the latest version of .NET Core SDK and Visual Studio 2019. Then you can go on to create a new project:
After generating the project, you can go to the Startup.cs class and see the ConfigureServices method, where are added all the services required for creation views in Razor and for Blazor Server.
Now, look at one of the views to see how it is created. If you have ever had contact with Razor before, it won’t be anything new to you. Here you can see HTML with C# insertions, that’s how it looks in Razor:
That’s not all but keep calm
In addition to the Blazor editions mentioned above, Microsoft plans and works on other solutions such as Blazor PWA, Blazor Hybrid and Blazor Native. In short, it can be said that these solutions are for desktop and mobile applications. As you can see, Microsoft strives for the framework to be as universal as possible.
In this article, I wanted to introduce you to Blazor and show you how technologies and solutions in web programming change. I think it’s worth following the development of this framework and learning about its capabilities. Maybe in some time the skill to write in Blazor will be desirable in the labour market?