1

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?

1
  • "force the MVC controllers to consume the APIs OR simply go with controllers and don't bother with the APIs for the time being." This is interesting. Consider how you would consume the APIs, via JavaScript rendered by the MVC views or by using a CLR httpclient to call your own server from that server. Obviously the latter would be silly Commented May 15, 2019 at 21:14

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.