C
C#4w ago
Order

Does blazor webassembly not contain a "backend" server?

So I'm a complete beginner when it comes to C# and dotnet development. Whenever I learn a new framework I always make the same app - a simple chat app, as it both helps me understand how to interface with a database, with real-time communication (websockets) and with dynamic client-side rendering. However I started following a tutorial about using clientR and I soon realized that my blazor project doesn't have a server!? What type of project should I create to have both a classic backend and a frontend, in my understanding the blazor wasm template is similar to "vite" in the javascript world (frontend only) so I can't really host my websocket server. I'm also using VSCode instead of VS2022 which is not helping as I have to use the CLI to create the project and I don't know what command I should use for a full stack type of project.
4 Replies
Order
OrderOP4w ago
yeah I use nextJS all the time, I've also used laravel plenty And I have used vite + a backend api but I don't understand the microsoft eco-system at all Swear to god I must have read that page 10 times I was avoiding Blazor Server because I thought it was like Ruby on Rails a.k.a. every click is a server request so I'm wrong and I should use Blazor server and I will still have client-side interactivity so how would I go about having client-side rendering + a server is there a template for that I wanted to learn the whole stack just for fun to compare to something like laravel / nextJS but it seems like there's no clear cut alternative, because if i go with WASM I don't have a back-end and if I go with server I can't (?) really opt-in for certain pages to be client-side rendered because for example it would be nice to have a chat window be client side rendered, as I don't want the page to refresh on every sent/received message When a standalone Blazor WebAssembly app uses a backend ASP.NET Core app to serve its files, the app is called a hosted Blazor WebAssembly app. I think THIS is what I'm looking for I want the backend to also host the websocket server for my example where do i find that nope that's what makes it hard i'm using vscode so I'm using the CLI and the docs often don't have the command necessairy to install specific templates for example when i run dotnet new webapp the pages have a .cshtml extension when i run dotnet new wasm they have the .blazor extension so why is it cshtml
Order
OrderOP4w ago
Microsoft be microsofting again so it's the same but different, or it's actually different nobody knows and what i did ( dotnet new webapp) is probably the server side rendered thing yeah I wanted to have a "full stack" experience but I guess that ain't really happening Okay, thanks I will read up more and see what I can do I think I'll just give up and install visual studio 2022 I believe there are templates I am looking for there i did dotnet new --list and it actualyl showed me all the templates found what im looking for it's dotnet new blazor and I was doing blazorwasm
skyslide22
skyslide224w ago
dotnet new blazor will allow you to use server side(signalr/websockets), server side rendering(static) or wasm, all in one project, can be configured per component/page < net.8.0 you had to decide between wasm and server, now you have all in one project + ssr

Did you find this page helpful?