I know the difference between WEB API and MVC. I also know that in asp.net core 1.0 there is only one type of controller that handles both MVC and API.
However, I have been watching many ASP.NET MVC tutorials recently and noticed that the instructor creates the Api folder inside the Controllers folder.
In this way, it splits all MVC controllers, which mainly deal with ViewModels, and uses the View function to tell MVC what view to display from the API controllers, which are mainly Dtos-related and seem to be strictly related to data, not to views .
You would think that there would be no API controllers in the MVC application, would you? Moreover, in kernel 1.0 you inherit one class: "Controller". But I assume that when you enable front-end frameworks such as Angular and the Kendo user interface that do a lot of ajax requests that you usually want to do with the api.
Here is my current understanding:
Use the MVC controller strictly for MVC only functions, such as indicating which view should be displayed, and passing along with it the presentation model.
Use the API controller primarily for ajax calls, never for bootstrapping a view, and never for MVC CRUD templates.
Can someone give me the best standards to follow when it comes to this?
source share