.netasp.net-web-apiarchitectureblazorn-tier-architecture

Blazor And .Net Web API Relation


I'm having difficulty choosing between the advantages and disadvantages of the scenarios I'm about to mention. I need feedback on which architecture to choose for my .NET application, using N-Tier Architecture and writing the frontend part with Blazor.

  1. Do you think I should integrate the frontend (Blazor) directly with the business layer? All Dependency Injection processes will be configured within the Blazor project.
  2. Should I expose the business layer with .NET WebAPI and integrate the frontend with the API?

I need an opinion about architecture.


Solution

  • Option 1 is only possible with Blazor Server. ViewModels might still be a good option but yes, you can directly call services.

    Option 2 is required for Blazor Wasm and optional for Blazor Server.

    What you pick depends entirely on what other requirements you have.