When one creates a ASP.NET Core project using Blazor, this presents some interesting architecture decisions. There are 3 different project templates.
- Blazor
- Blazor (ASP.NET Core hosted)
- Blazor (Server-side in ASP.NET Core)
Question 1
I'm trying to understand the purpose or benefit of the "Blazor (Server-side in ASP.NET Core) " template or approach to structuring a project. Why have a .NET core app serve up another .NET core app ? Or am I missing something?
Given the different hosting models explained here.
https://blazor.net/docs/host-and-deploy/hosting-models.html
Couldn't this simply be one project that uses server-side Blazor rather than 2?
Question 2
If I am looking at architecture like that shown in the image below, shouldn't I start with the "ASP.NET Core Hosted" template, then change the .Client project to use the "server-side" framework? That way, I still have a callable api that can be accessed from another app if needed? Or I suppose I can still use the "Server-side" template, which would pre-set all the startup plumbing for firing up the Client with the server-side hosting model, and combine this with adding my own API controllers to the .Server project, which would be called via the business rules library as per the diagram.
Question 3
At some point, I might want to switch the .Client app to use webassembly when the tooling/debugging support becomes better. I don't think the architecture I'm suggesting prohibits that? I would just change out the startup code in the .Server app, replace the reference to blazor.server.js with the blazor.webassembly.js and a few other things and I should be golden. Am I off base here?
Notes on architecture:
- Client app needs access to a resource via some CRUD operation, so it makes a call into a method in the Business Rules class library
- Business rules library references a class library that contains "dumb" POCO classes that represent various domain models. Makes a call to an api
- API controller/action then calls a Data library or repository that manages a Entity Framework DbContext for fetching/updating the data in the Db
- Both the Business rules library, the Data library and the API all reference the "Models" library.
