Should I opt for ASP.NET Core Web API or ASP.NET Core MVC when integrating with Angular?

I’m in the process of developing a web application that utilizes .NET Core for the backend and Angular for the frontend. One of the key questions I have is whether to select ASP.NET Core Web API or ASP.NET Core MVC for the backend.

From what I understand, Angular operates on the MVVM model rather than the MVC structure. This leads me to think that I might not require ASP.NET Core MVC for my application. Nonetheless, I frequently encounter tutorials and materials emphasizing ASP.NET Core MVC for use with Angular.

Could anyone clarify which method is more appropriate for working with Angular and why? Additionally, what are the pivotal distinctions between these two frameworks when incorporating a separate Angular frontend?

// Sample code illustrating my goals
public class ProductController : ControllerBase
{
    public async Task<IActionResult> RetrieveProducts()
    {
        var allProducts = await _productService.GetAllAsync();
        return Ok(allProducts);
    }
}

I want to ensure I select the correct architectural approach right from the beginning.

totally agree! web api is deff better for this. mvc just complicates things since angular is managing the front. stick with json endpoints to keep it simple and clean. no need for extra baggage!

Web API wins hands down for Angular projects. I’ve used this combo on multiple builds and it’s perfect - you get clean JSON endpoints without all the view rendering bloat that comes with MVC. Those confusing MVC tutorials are probably outdated or meant for full-stack apps that still do server-side rendering. Your code sample with ControllerBase is spot on. Web API keeps your backend laser-focused on data and business logic while Angular owns the UI completely. You’ll get cleaner architecture, easier testing, and better performance since you’re not dragging around MVC middleware and view engines you don’t need.

interesting question! what data are you exchanging between angular and your backend? mostly crud ops or smth more complex? ur choice might also depend on whether u need server-side rendering.