Serving Industries Worldwide

Innovative Ways - Satisfied Clientele

ASP.NET Core Blazor Hosting Models


Listening is fun too.

Straighten your back and cherish with coffee - PLAY !

 
 

ASP.NET_Core_Blazor

A blazer is a web framework that is application-based within a browser. Designed to run server-side in NET runtime (Blazer WebAssembly) or ASP.NET Core (Blazer Server). Regardless of the hosting model, the application and component models are identical.

Table of Content

Blazor WebAssembly

The primary Blazor hosting model is running client-side within the browser on WebAssembly. Blazor application is dependencies, and the .NET runtime is downloaded to the browser. The application runs directly on the browser UI thread. Updates the UI and event handling happen within the same process. The application is assets are deployed as static files on an internet server or service capable of serving static content to the client.

ai-Hiring-banner

Figure: Blazor WebAssembly application
 

When a Blazor WebAssembly application is created for deployment without a backend ASP.NET Core application to provide its files, the application is called a standalone Blazer WebAssembly application. When an app is created for deployment with a backend app to provide its files, the app is called a hosted Blazer WebAssembly application. The hosted Blazer application client application typically interacts with a backend server application on the network using Web API calls or SignalR.

Blazor.Webaswebel.JS script framework and handles provided by:

  1. Download .NET runtime, application, and application dependencies.
  2. Start runtime to run the application.

The Blazor WebAssembly hosting model offers several advantages:

  1. There are no .NET server-side dependencies. Once the application is downloaded to the client it is fully functional.
  2. Client resources and capabilities are absolutely leverage.
  3. The work server is offloaded to the client.
  4. ASP.NET core web server isn't needed to host the application. Serverless deployment scenarios are possible, like serving an application from a Content Delivery Network (CDN).
   

The Blazer WebAssembly Hosting model has the following limitations:

  1. The Blazer WebAssembly Hosting model has the following limitations:
  2. Requires enabled client hardware and software (for example, web-based support).
  3. The download size is large and apps take longer to load.
  4. .NET runtime and tooling support are less mature as an example, there are limitations in .NET standard support and debugging.

To create a Blazor WebAssembly application, see tooling for ASP.NET Core Blazor.

The Hosted Blazor app supports docker containers. Docker Support in Visual Studio, right-click on the project of the hosted Blazor WebAssembly solution and select Add> Docker Support.

Blazor Server

With the Blazor Server Hosting model, the application is run on the server from the ASP.NET core application.

ai-Hiring-banner

Figure: Blazor Server Hosting model
 

ASP.NET refers to the application's Startup class for adding a core application:

  1. Server-side services.
  2. Application of request handling pipeline.

On the client, the blazor.server.js script establishes a SignalR reference to the server. The script is delivered to the client-side application from a source embedded within the ASP.NET Core Shared Framework. The client-side application is responsible for maintaining and restoring the application state as required.

The Blazor server hosting model offers several advantages:

  1. The download size is considerably smaller than the Blazor WebAssembly app, and also the app loads much faster.
  2. The application takes full benefit of server capabilities, together with the use of any .NET Core compatible API.
  3. The .NET core on the server is used to run the application, so it exists. NET tooling, like debugging, works as expected.
  4. The .NET/C # code base of the application, including its component code, is not provided to the client.

The Blazor Server Hosting model has the following limitations:

  1. Higher latency usually exists. Each user interaction includes network hop.
  2. No offline support. If the client connection fails, the application stops working.
  3. Scalability is difficult for applications with multiple users. The server should manage multiple client connections and manage client state.
  4. An ASP.NET Core server is required to serve the application. Circumstances of serverless deployment aren't possible, like serving an application from a content delivery network (CDN).
 

Are You Looking for Dedicated ASP.Net Core Developer ?

Your Search ends here.

 

The Blazer Server application model supports docker containers. For Docker support in Visual Studio, right-click on the project in Visual Studio and choose Add> Docker Support.

Comparison with server-rendered UI

One way to understand Blazor Server apps is to understand however it differs from traditional models for rendering UI in ASP.NET Core apps using Razor views or Razor Pages. Both models use the Razor language to explain HTML content for rendering, but they differ significantly in however mark-up is rendered.

When a razor page or view is rendered, each line of razor code releases HTML in text form. After rendering, the server disposes of the page or view instance, includes any state that was manufactured. When a second request for a page occurs, for instance when server validation fails and a validation summary is displayed:

  1. The whole page is rendered in HTML text again.
  2. The page is been sent to the client.

The Blazer app is made up of reusable elements of UI called components. The component contains C# code, mark-up, and other components. When the component is rendered, Blazer produces a graph of similar content components such as HTML or XML Document Object Model (DOM). This graph includes the component state contained in the properties and fields. Evaluates the blazer component graph for binary representation of mark-up. The binary format can be:

  1. Converts to HTML text (during prerendering).
  2. Used to effectively update mark-up during regular rendering.

Circuits

A Blazor Server application is built on top of the ASP.NET Core SignalR. Each client interacts with the server over one or more SignalR connections known as circuits. A circuit is the abstraction of a Blazor over SignalR connections that can withstand temporary network interruptions. When the Blazer client sees that the SignalR connection is disconnected, it attempts to reconnect to the server using the new SignalR connection.

Each browser screen (browser tab or iframe) is connected to the Blazor Server app used in the SignalR connection. This is yet another important difference compared to typical server-rendered applications. In a server-rendered application, opening the same application in multiple browser screens does not usually translate into additional resource demand on the server. In the Blazor Server application, every browser screen requires a separate circuit and separate instances of component state to be operated by the server.

Conclusion

In this article, we have learned about ASP.NET Core Blazor Hosting Models. If you want to serve a large number of users and do not have secret code running, use WASM. It also provides offline support. Use Blazor Server if you need to load the first page quickly or if you have sensitive code that you do not want to send to the browser.

ASP.NET_Core_Blazor

A blazer is a web framework that is application-based within a browser. Designed to run server-side in NET runtime (Blazer WebAssembly) or ASP.NET Core (Blazer Server). Regardless of the hosting model, the application and component models are identical.

Table of Content

Blazor WebAssembly

The primary Blazor hosting model is running client-side within the browser on WebAssembly. Blazor application is dependencies, and the .NET runtime is downloaded to the browser. The application runs directly on the browser UI thread. Updates the UI and event handling happen within the same process. The application is assets are deployed as static files on an internet server or service capable of serving static content to the client.

ai-Hiring-banner

Figure: Blazor WebAssembly application
 

When a Blazor WebAssembly application is created for deployment without a backend ASP.NET Core application to provide its files, the application is called a standalone Blazer WebAssembly application. When an app is created for deployment with a backend app to provide its files, the app is called a hosted Blazer WebAssembly application. The hosted Blazer application client application typically interacts with a backend server application on the network using Web API calls or SignalR.

Blazor.Webaswebel.JS script framework and handles provided by:

  1. Download .NET runtime, application, and application dependencies.
  2. Start runtime to run the application.

The Blazor WebAssembly hosting model offers several advantages:

  1. There are no .NET server-side dependencies. Once the application is downloaded to the client it is fully functional.
  2. Client resources and capabilities are absolutely leverage.
  3. The work server is offloaded to the client.
  4. ASP.NET core web server isn't needed to host the application. Serverless deployment scenarios are possible, like serving an application from a Content Delivery Network (CDN).
   

The Blazer WebAssembly Hosting model has the following limitations:

  1. The Blazer WebAssembly Hosting model has the following limitations:
  2. Requires enabled client hardware and software (for example, web-based support).
  3. The download size is large and apps take longer to load.
  4. .NET runtime and tooling support are less mature as an example, there are limitations in .NET standard support and debugging.

To create a Blazor WebAssembly application, see tooling for ASP.NET Core Blazor.

The Hosted Blazor app supports docker containers. Docker Support in Visual Studio, right-click on the project of the hosted Blazor WebAssembly solution and select Add> Docker Support.

Blazor Server

With the Blazor Server Hosting model, the application is run on the server from the ASP.NET core application.

ai-Hiring-banner

Figure: Blazor Server Hosting model
 

ASP.NET refers to the application's Startup class for adding a core application:

  1. Server-side services.
  2. Application of request handling pipeline.

On the client, the blazor.server.js script establishes a SignalR reference to the server. The script is delivered to the client-side application from a source embedded within the ASP.NET Core Shared Framework. The client-side application is responsible for maintaining and restoring the application state as required.

The Blazor server hosting model offers several advantages:

  1. The download size is considerably smaller than the Blazor WebAssembly app, and also the app loads much faster.
  2. The application takes full benefit of server capabilities, together with the use of any .NET Core compatible API.
  3. The .NET core on the server is used to run the application, so it exists. NET tooling, like debugging, works as expected.
  4. The .NET/C # code base of the application, including its component code, is not provided to the client.

The Blazor Server Hosting model has the following limitations:

  1. Higher latency usually exists. Each user interaction includes network hop.
  2. No offline support. If the client connection fails, the application stops working.
  3. Scalability is difficult for applications with multiple users. The server should manage multiple client connections and manage client state.
  4. An ASP.NET Core server is required to serve the application. Circumstances of serverless deployment aren't possible, like serving an application from a content delivery network (CDN).
 

Are You Looking for Dedicated ASP.Net Core Developer ?

Your Search ends here.

 

The Blazer Server application model supports docker containers. For Docker support in Visual Studio, right-click on the project in Visual Studio and choose Add> Docker Support.

Comparison with server-rendered UI

One way to understand Blazor Server apps is to understand however it differs from traditional models for rendering UI in ASP.NET Core apps using Razor views or Razor Pages. Both models use the Razor language to explain HTML content for rendering, but they differ significantly in however mark-up is rendered.

When a razor page or view is rendered, each line of razor code releases HTML in text form. After rendering, the server disposes of the page or view instance, includes any state that was manufactured. When a second request for a page occurs, for instance when server validation fails and a validation summary is displayed:

  1. The whole page is rendered in HTML text again.
  2. The page is been sent to the client.

The Blazer app is made up of reusable elements of UI called components. The component contains C# code, mark-up, and other components. When the component is rendered, Blazer produces a graph of similar content components such as HTML or XML Document Object Model (DOM). This graph includes the component state contained in the properties and fields. Evaluates the blazer component graph for binary representation of mark-up. The binary format can be:

  1. Converts to HTML text (during prerendering).
  2. Used to effectively update mark-up during regular rendering.

Circuits

A Blazor Server application is built on top of the ASP.NET Core SignalR. Each client interacts with the server over one or more SignalR connections known as circuits. A circuit is the abstraction of a Blazor over SignalR connections that can withstand temporary network interruptions. When the Blazer client sees that the SignalR connection is disconnected, it attempts to reconnect to the server using the new SignalR connection.

Each browser screen (browser tab or iframe) is connected to the Blazor Server app used in the SignalR connection. This is yet another important difference compared to typical server-rendered applications. In a server-rendered application, opening the same application in multiple browser screens does not usually translate into additional resource demand on the server. In the Blazor Server application, every browser screen requires a separate circuit and separate instances of component state to be operated by the server.

Conclusion

In this article, we have learned about ASP.NET Core Blazor Hosting Models. If you want to serve a large number of users and do not have secret code running, use WASM. It also provides offline support. Use Blazor Server if you need to load the first page quickly or if you have sensitive code that you do not want to send to the browser.