Blog for Junior Developers C#/.NET

Thursday, October 24, 2024

In Blazor, you can create different types of apps that can be separated based on the hosting model. The first type is Blazor Server based on SignalR. In this article, I will introduce you to this topic.

Introduction to Blazor Server (SignalR)

Introduction


In Blazor Server, everything is done on the ASP.NET Core application server. That is, the application code, the application logic is on the server. And all updates in the client, i.e. in the browser - are handled using SignalR using Web Sockets. So it looks like this: when you first run the application, you download the application in a reduced size, you do not download the entire application as in the case of the Web Assembly version, and here, then, all user interactions are sent to the server using Web Sockets, to which the return from the server comes and the website is updated. This solution has its advantages and disadvantages.


Disadvantages


As for the disadvantages:


Slower mode of application operation. Every response comes from the server through SignalR, so you may notice a slight delay on each request, which can be annoying at times.

The second disadvantage is scalability issues. If you have a lot of users on your website and everyone is communicating with the server via SignalR all the time, this can unfortunately overload the server and this is where problems can arise with a very large number of users. Also, with a larger number of users, you would simply have to have a larger, better server.


Advantages


As for the advantages:

In this mode, the application download size is much smaller than in the case of Web Assembly, so the first connection will be faster.

The application uses server resources, so we have all the server-side security here. We can easily use various server-side libraries. The code is not shared with the client.

Low browser requirements. Blazor Server will run flawlessly on most browsers, including older versions.

That's it for the first hosting model, and in the next article I will introduce you to Blazor WebAssembly.


Blazor School


By the way, if you would like to learn Blazor from the inside, consider joining my online training - Blazor School (more information here - https://blazor-school.com/).

Author of the article:
Kazimierz Szpin

KAZIMIERZ SZPIN
Software Developer C#/.NET, Freelancer. Specializes in ASP.NET Core, ASP.NET MVC, ASP.NET Web API, Blazor, WPF and Windows Forms.
Author of the blog CodeWithKazik.com

Previous article - 7 Common Mistakes Programmers Make When Writing Unit Tests
Dodaj komentarz
© Copyright 2024 CodeWithKazik.com. All rights reserved. Privacy policy.
Design by Code With Kazik and Modest Programmer.