'Blazor - FrontEnd or Backend?
Recently i worked on one project, where Angular is used as the front end framework and springboot is backend. Now i moved to .NET projects .I understood that Blazor supports two hosting models, client side hosting model and server side hosting model. Now i am going to start .NET project with blazor. I have created REST API for the project.Now i have to use Blazor in that project.Here my doubt comes.
1)Blazor web assembly is for front end (or) back end ?
2)Blazor Server app is for front end (or) back end?
Solution 1:[1]
Just a few words of explanation.
In traditional web design, you have a server which assembles code using stuff the user's browser must not have access to: database searches, proprietary logic, files and so on. That's usually done with C#, PHP, etc. That's the back end.
Front end is the stuff that can and IS done in the user's browser: changing text, collecting input, handling mouse events and so on. That's usually done with JavaScript. This is because JavaScript is safer to run on a browser-- it doesn't have access to your drives and so on.
How web pages work is that you collect form information-- type in text, set the state of checkboxes, etc., then package ALL that information with a form submission to the server. The server then processes all that information, REBUILDS the entire page, and sends a whole, complete page back to the client's browser. It's a very big transaction.
Blazor doesn't do that. Everything on a page can be individually updated at any time without sending large blocks of information back and forth. Every event on a page (button click and so on) can be sent as an individual event call to the server, and you can return either no changes (for example if you're just saving some info to a database), or by changing any or all the content on the page.
In other words, there's not really a very meaningful distinction between front end anymore: the visible page is an expression of the current state of code, rather than a new object that gets rebuilt every time you click a button.
And just to clarify, it's a very robust connection-- you can check the contents on a textbox in real time as you type each character, or you can send updates to the user while you grind through 20 file uploads: "Processing image 1/20" and so on.
Solution 2:[2]
WASM runs in the browser on the client. If your codes run only on browser (not dependents on server) you can use WASM. However you can suppose it as a front end app and use WebAPI to connect to the server. Blazor Server is front end and back end (both).
Solution 3:[3]
in nutshell, Blazor web assembly WASM: it is a front end where you can use the C# instead of Javascript ( you can still use javascript and call js function), for that to call any function/ Web API you have to send an HTTP request to get the data from your endpoint.
Blazor Server is an app that uses server resources, and all the interactions between the user and the server happen based on SingalR for real-time connection. so that means any kind of request will process on the server-side and respond to the user (Client Browser), so this means this type of application will use the traditional way (client-server app), all the layers of your apps are available in server-side, and your front end will render dynamically based on the requested contents.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Ali Borjian |
| Solution 3 | Mohammed Jawad |
