Im new to Blazor and started using it with .NET 8 Version. Im confused on the part where even though i have selected WebAssembly render mode VS still created two separate projects. Whats the need for the startup project that references the client project? why not just combine the two? The startup projects contains files like Error.razor App.razor and etc etc.
Take note that the way I thought of this initially is that Blazor Web APP WASM would create a single project and I would just consume an existing API. Which is also a very typical architecture for other frontend frameworks.
Can someone please explain whats the advantage of the other/startup project when im on WebAssembly RenderMode? What use do i have for that?
Im new to Blazor and started using it with .NET 8 Version. Im confused on the part where even though i have selected WebAssembly render mode VS still created two separate projects.
Well according to your question, yeah there might be some confusion about the two separate projects when using Blazor WebAssembly, Yet it definitely provides a wide range of flexibility which includes, separation of the client and server projects in Blazor WebAssembly hosting model provides a clear separation of concerns.
Not only this, it obviously allows for server-side functionality, facilitates integration with ASP.NET Core features, and offers flexibility in hosting and deployment options. While it might seem different from other frontend frameworks at first, it aligns well with the server-client architecture and the capabilities of the ASP.NET Core framework.
Why not just combine the two? The startup projects contains files like Error.razor App.razor and etc etc.
Blazor WebAssembly can be standalone for simple, offline apps, but a separate server project unlocks improved security, scalability, complex server tasks, and potential offline features, making it ideal for more elaborate and demanding applications.But if you combine them together the complexity would increase and this might make the application less manageable. If you look at from design pattern point of view where decoupling or loosely coupled app are encouraged and tightly decoupled applications are not recomended.
Therefore, as your application grows or requires server-side functionality, having a separate server project provides a scalable and maintainable architecture in those scenario its better to split your project this way.
But why is there a separate need for a server to host the web assembly? what does it improve for the Web Assembly Client? When we create stand alone blazor wasm it doesnt have that. im just curious on that part since API endpoint is pretty self explanatory
As said earlier, its because of maintainable design or architectural pattern. If your app primarily displays information and handles user interaction without complex server-side logic, a standalone approach is efficient and avoids hosting costs. But while offline access is limited depending on API availability, some functionality can still work without an internet connection.
Apart from that, the server can act as a proxy for accessing backend APIs. This enhances security by keeping sensitive API credentials and logic on the server and only exposing specific data points to the client. So, while standalone Blazor WebAssembly offers simplicity and offline capabilities, the server project significantly improves.
Note: Tough it creates some confusions but Architecturally, it provides a lot of benefits. However, its completely depends on the needs, scenario and requirements. In addition, Please have a look at this official documents.
You have created a "Blazor Web App". If you set "Interactive Render Mode" to "WebAssembly" in the new project wizard, you will get both:
If you already have the server and need only the web assembly, create a new "App WebAssembly Razor".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With