Blazor: More on App Options
blazor blazor web dnetcore aspnetcore
My take on a succinct comparison of Blazor App options.
Preamble
From a command line there are two options with ```dotnet new`` for creeating Blazor apps:
- Blazor Server App blazorserver [C#] Web/Blazor
- Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly
That is …
dotnet new blazorserver
and dotnet new blazorwasm
In Visual Studio you just choose Create a New Project - Blazor App and the differentiation follows in a subsequent dialog.
So what are all of the optons with creating a new Blazor app and what are the differences?
I have discussed this before, as have many others, but lets go into more detail.
Commonality
- Both are hosted on a web site
- Both render content to be displayed in a client’s browser
- Both use .NET Core for coding
- Both use ASP.Net Core with .razor pages for dynamic rendering of HTML content
Blazor Server
A Blazor server generates rendered content before the HTTP Request is returned to the browser. Each call to razor code (behind) requires a request to the server. That way there is no compiled code that is delivered to the browser. The impost to client’s browser is in latency rather than footprint. For simple functionality where you do need some internet activity such as to an online database, this is a good option. This is the case for the AEGateLog app as per the two previous blogs posts. The athletes want to quickly enter and submit their name and mobile number and be done.
Using Visual Studio to create a Blazor Server _(or as dotnet new command line options) there are only 2 basic options (ignoring Docker)
- https support
- Command line option:
--no-https
true/false, default false (i.e. https support is enabled)
- Command line option:
- Add an Authentication method
- Command line option
-au|--auth
eg None,Individual, Windows etc. Default is None - See [Microsoft Dox}(https://docs.microsoft.com/en-us/aspnet/core/security/authentication/individual?view=aspnetcore-2.1#win)
- Command line option
Blazor WebAssembly
Besides the options listed for a Blazor Server there are another two major additional options with a Blazor Wasm project:
- ASP.NET Core hosted
- Command line option
-ho|--hosted
true/false Default false
- Command line option
- Progressive Web Application
- Command line option
-p|--pwa
true/fale Default false
- Command line option
With a Blazor Web Assembly, the client side footprint is much bigger. rasor code (behind) is compiled and uploaded to the client facilating client side rendering of pages. The uploaded DLLs are kept in a sandbox and the app can run without further HTTP requests to web server. For example a Wasm Calculator app could be facilitated in the browser in this manner. The uploaded DLLs are NOT installed, like ActiveX and Java Applets, in the client, or the client’s broswer. When the browser cache is cleared they are gone;(NB Looking for authoritive statement on this) except that if it is a Progessive Web App (PWA) then the user get the option to keep the app’s DLLs. In this case an icon for the app is placed on the desktop.
If the Web Assembly App requires interaction with enities, such as a remote database, then there needs to be some server side support for the app. For this capability, the ASP.NET Core hosted
option is taken. The rendering will still be performed on the client side but HTTP requests will be sent to server to get the required data. Data can be cached by the app and only be sent or requested when changes are envisaged.
Topic | Subtopic | |
This Category Links | ||
Category: | Blazor Index: | Blazor |
Next: > | Blazor | Some activities |
< Prev: | Blazor How To | Server App with GPS |