« Blazor » : différence entre les versions
(7 versions intermédiaires par le même utilisateur non affichées) | |||
Ligne 13 : | Ligne 13 : | ||
* Pas de debug avec VScode | * Pas de debug avec VScode | ||
* Ne recharge pas la page lors de modification, il faut relancer le serveur.}} | * Ne recharge pas la page lors de modification, il faut relancer le serveur.}} | ||
= [https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models Hosting models] = | |||
{| class="wikitable wtp" | |||
! Hosting model | |||
! Description | |||
|- | |||
| Blazor Server || run components server-side. UI updates, event handling, and JavaScript calls are handled over a SignalR connection using the WebSockets protocol. | |||
|- | |||
| Blazor WebAssembly || runs components client-side in the browser on a WebAssembly. | |||
|- | |||
| Blazor Hybrid || native client (MAUI, WPF) which renders web UI to an embedded Web View control. | |||
|} | |||
= [https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-7.0#blazor-server Blazor Server description] = | = [https://learn.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-7.0#blazor-server Blazor Server description] = | ||
Components are executed on the server. UI updates, event handling, and JavaScript calls are handled over a SignalR connection using the WebSockets protocol.<br> | Components are executed on the server. UI updates, event handling, and JavaScript calls are handled over a SignalR connection using the WebSockets protocol.<br> | ||
On the client, the Blazor script establishes the SignalR connection with the server. | On the client, the Blazor script establishes the SignalR connection with the server.<br> | ||
The state on the server associated with each connected client is called a circuit.<br> | |||
Circuits aren't tied to a specific network connection and can tolerate temporary network interruptions and attempts by the client to reconnect to the server when the connection is lost. | |||
= How Blazor Server is working = | |||
Whenever the browser triggers a registered event (e.g. click on a button), it sends to the server a message saying that the button was clicked.<br> | |||
The server executes the code associated with the event, manipulating the server's copy of the page, and replies a JSON message with the delta between server and client. | |||
= [https:// | = [https://scientificprogrammer.net/2019/08/18/pros-and-cons-of-blazor-for-web-development/ Blazor Server Pros / Cons] = | ||
{{ListPlusMinus|type=plus|list= | {{ListPlusMinus|type=plus|list= | ||
* .NET-based web framework that uses the C# and Razor languages. | * .NET-based web framework that uses the C# and Razor languages. | ||
Ligne 24 : | Ligne 42 : | ||
}} | }} | ||
{{ListPlusMinus|type=minus|list= | {{ListPlusMinus|type=minus|list= | ||
* | * Performances: every client actions are routed to the server and will be delayed by the network latency and will use bandwidth. | ||
* No offline support | |||
* Reduced scalability: with SignalR there is a limit to how many simultaneous connections can be handled from the clients. | |||
}} | }} |
Dernière version du 26 octobre 2023 à 21:30
Liens
- Introduction to ASP.NET Core Blazor
- How to implement JavaScript Interop in Blazor
- How to create an application using Blazor and Entity Framework Core
- ASP.NET Core Blazor CRUD using Entity Framework and Web API
Description
- Développement frontend avec C#
- Intégration des bibliothèques .NET existantes (nuget)
|
Hosting models
Hosting model | Description |
---|---|
Blazor Server | run components server-side. UI updates, event handling, and JavaScript calls are handled over a SignalR connection using the WebSockets protocol. |
Blazor WebAssembly | runs components client-side in the browser on a WebAssembly. |
Blazor Hybrid | native client (MAUI, WPF) which renders web UI to an embedded Web View control. |
Blazor Server description
Components are executed on the server. UI updates, event handling, and JavaScript calls are handled over a SignalR connection using the WebSockets protocol.
On the client, the Blazor script establishes the SignalR connection with the server.
The state on the server associated with each connected client is called a circuit.
Circuits aren't tied to a specific network connection and can tolerate temporary network interruptions and attempts by the client to reconnect to the server when the connection is lost.
How Blazor Server is working
Whenever the browser triggers a registered event (e.g. click on a button), it sends to the server a message saying that the button was clicked.
The server executes the code associated with the event, manipulating the server's copy of the page, and replies a JSON message with the delta between server and client.
Blazor Server Pros / Cons
- .NET-based web framework that uses the C# and Razor languages.
- easy integration of Javascript libraries with JSInterop.
- Performances: every client actions are routed to the server and will be delayed by the network latency and will use bandwidth.
- No offline support
- Reduced scalability: with SignalR there is a limit to how many simultaneous connections can be handled from the clients.