ASP.NET Core 3 Service Registration – AddControllers() AddControllersWithViews() AddRazorPages()
With v3 and higher, there are several ways to register MVC. This way the application can only use what it requires, not the whole framework. This would result with a smaller size and being not sure, better performance.
If you are developing an API, go with this. This is only for API-related features, Views or pages are not supported.
This adds API + Views but not Pages. If you “dotnet new mvc”, it uses this code.
This adds support for Razor Pages and minimal controller support. If you “dotnet new web”, it uses this code.
These can be combined as well. The following is equivalent to calling AddMvc in ASP.NET Core 2.2: