When I create a new Blazor Web App both the server and client projects contain a program.cs file, as expected. Do I need to configure my dependency containers in both program.cs files, once in the server project and again in the client project?
I’ve been adding my containers to both files but it seems like a lot of code duplication. Is there a project structure that only requires the containers in one place regardless of where they’re being injected. I’m using Clean Architecture.
I initially had all my containers in the server project but I was getting "no registered service" errors, same if I put them all in my client project.
I must be doing something wrong, right?
Nothing wrong, it just can be very confusing. It's all a matter of how your application is configured.
If you're pre-rendering then the first render of the page takes place on the server, and therefore you need all the necessary services registered on server for the initial page to pre-load After the initial pre-render, the application switches to WASM running on the client, and thus it also needs all the necessary services.
If you disable pre-rendering, then you only need client side services.