Should all my asp.net MVC controllers use Web APIs?
https://softwareengineering.stackexchange.com/questions/391443
-
24-02-2021 - |
문제
The thing that I don't understand is the prioritization between MVC Controllers and Web APIs.
Consider I want to make a website. I can either program to APIs and for the presentational layer, force the MVC controllers to consume the APIs OR simply go with controllers and don't bother with the APIs for the time being.
What is the thing that I have to really consider? is there anything I'm forgetting?
해결책
You may use Controller
for rendering the views
. In AP.NET MVC, it basically works similar to that of WEB-API
, but it's derived from APIController
class instead of Controller
class. As the name states Web API, controllers meant to handle the serialised requests.
You can also create a Web API project using the "Web API" template. The Web API template uses ASP.NET MVC to provide API help pages. In general, you don't need to know ASP.NET MVC to use Web API.
So in your case, you can opt to work with MVC, since you need to return some views to return.
Consider Web-API
only when you need to work with some external clients consume using HTTP
requests.
Refer the links below for a detailed official description. For Web-API For MVC