Pages

Men

rh

12/26/2022

 

Blazor Server:

  • With the Blazor Server hosting model, the app is executed on the server from within an ASP.NET Core app.
  • UI updates, event handling, and JavaScript calls are handled over a SignalR connection
  • A Blazor Server application runs on an ASP.NET Core backend and can be accessed using a browser.
  • The ASP.NET Core application can either be hosted self-contained or running on IIS.
  • Blazor Server uses a small JavaScript file to run and HTML and CSS to rendering its user interface. Blazor Server does not use WebAssembly. On the server-side, the Blazor application contains the .NET code and handles a copy of the Document Object Model (short DOM) for every client. If the user interacts with the application, Blazor will send an event to the server using a persistent SignalR WebSocket connection. The server will decide how to react to the user input and return changes to the DOM or execute backend functionality.
  • Every interaction triggers a network communication between the client and the server. Unlike JavaScript web frameworks that handle the user interaction client-side, Blazor Server handles user interaction on the server-side.
  • Advantages:
    Blazor Server only sends data to the client that is needed at the moment of user interaction. When we launch the application in the browser, only the first page gets downloaded and rendered.
  • Let’s compare that to a typical React or Angular application. In a single page web application based on any popular JavaScript web framework, you bundle your application and send the entire application to the client before it runs. Depending on the application and framework size, you send a lot of data to the client.
  • Using Blazor Server, you only send the data required to render the application initially. In short, Blazor Server applications start very quickly because the client does not have to download and execute a lot of code to get started. Because the download size is small, the rendering is also quick. The browser does not have to initialize a big single page application. It just renders the HTML and CSS for the initial page.
  • Blazor Server supports every browser that supports HTML and CSS. It does not require WebAssembly support, which makes Internet Explorer 11 a supported browser. If you’re building corporate applications and still have the requirement to support Internet Explorer 11, Blazor Server is the only viable rendering model.
  • The .NET code of a Blazor Server application runs on the server-side. It means that the .NET code remains on the server and will not be sent to the client. Therefore, business logic cannot be decompiled, and your sensitive business algorithms cannot be analyzed.
  • Blazor Server provides a simple project structure and allows access to the business logic from your user interface classes directly. You don’t need to implement an API layer to access data from the database.
  • All in all, Blazor Server allows you to be very productive and create modern single-page web applications without worrying about installing hundreds of JavaScript packages. You can write the client and server code using C#.
    Disadvantages:
  • Usually, React, or Angular applications build to static HTML, CSS, and JavaScript files that can be hosted as static resources on any webserver. However, when you use Blazor Server, you need to run ASP.NET Core on the server because the application is not compiled into static artifacts. With every user interaction, the server evaluates the appropriate response to the client.
  • Another thing to keep in mind is that every user interaction triggers a network communication. As we learned, the server holds a copy of every client’s DOM, and for every user interaction decides what to render next. This architecture does not allow offline support.
  • A steady and reliable network connection is a requirement to run a Blazor Server application successfully. Every user interaction evaluates on the server-side, and the results need to be transmitted to the client afterward. Without a steady internet connection, this model does not work.
  • Last but not least, remember that the server handles the requests of every client. If running on Azure, a standard virtual machine for 50$ a month can handle around 5000 concurrent client connections. For a 200$ a month machine, you already can handle about 20’000 concurrent client connections.
  • All source of information collected from learn Microsoft Documentation page.

    No comments :

    Post a Comment