C
C#2y ago
Allan

Questions regarding Blazor (WASM, Server etc.)

Hello, I'm starting a tiny project and I wanted to explore the possibilities of Blazor. I have some questions about the different possible things with Blazor because there's something I don't understand properly between the client-side and server-side. I first made a WASM Blazor app, so it seems everything is done client-side. I wanted to know how to make server-side treatments (such as Database requests): - Do I have to create my own controllers in the app? - When you inject Services within your page, is the code within the service executed server-side or client-side? Can you chose this behaviour? Then, is it bad to make a WASM Blazor App if I'm going to make some things server-side? Should I instead make a Blazor Server app, or a Hosted WASM Blazor app?
2 Replies
mindhardt
mindhardt2y ago
Blazor wasm is just a frontend that can run in browser, it has no server by default If you need a backend consider using hosted wasm or Blazor server With the first approach you connect to your backend with http/websockets/etc, second is rendered on server by default If you create a fresh hosted wasm with your IDE or dotnet new it shows you how you can call rest API from withing the app (/weatherforecast) Everything that happens in wasm stays in the browser
Allan
AllanOP2y ago
Thanks Hin, it's something I wanted to clarify on my head
Want results from more Discord servers?
Add your server