I want to develop an application with React and ASP.Net Core. The default template comes with MVC architecture. What's the point of MVC when using React with ASP.NET Core? Isn't WebAPI as backend and React as frontend a better approach?
Thank you!
I want to develop an application with React and ASP.Net Core. The default template comes with MVC architecture. What's the point of MVC when using React with ASP.NET Core? Isn't WebAPI as backend and React as frontend a better approach?
Thank you!
As @juunas commented, it's all MVC. More accurately, it's all "Core", but the extensions methods used to bootstrap the framework all use "MVC" in their name. If you don't need view rendering and such, it's possible you can get by with doing services.AddMvcCore(), instead of services.AddMvc(). That will reduce the service load slightly, but also may not include everything you might want to use.
If you refer to the source, you can see that services.AddMvc() first calls AddMvcCore and then continues to also add:
builder.AddApiExplorer();
builder.AddAuthorization();
AddDefaultFrameworkParts(builder.PartManager);
// Order added affects options setup order
// Default framework order
builder.AddFormatterMappings();
builder.AddViews();
builder.AddRazorViewEngine();
builder.AddRazorPages();
builder.AddCacheTagHelper();
// +1 order
builder.AddDataAnnotations(); // +1 order
// +10 order
builder.AddJsonFormatters();
builder.AddCors();
If you don't need any of that, you can just go with AddMvcCore and call it a day. If you do need certain bits, you can always add those manually, i.e.:
services.AddMvcCore();
services.AddJsonFormatters();
services.AddCors();
// etc.