Thursday, April 19, 2018

Controller vs ApiController

1) You can use controller to render your normal views only. But using the ApiController action only returns the data which is serialized and sent to client.
So, that you can use it any Html based application.

2) You can self hosting using ApiController but not from MVC Controllers.

3) Web Api Controller inherits the ApiController class instead of the Controller class.

4) APIControllers is a lightweight architecture excepting the web Apps.

5)  MVC Controller shows the URL Samples matching the default route pattern"{controller}/{action}/{id}". and the ApiController shows "api/{controller}/{id}".

6) Web API Supports the self hosting, content negotiation where the MVC doesn't support it.

7) Use Controller when - If you're writing an HTML based web/internet application (with the occasional AJAX call returning json here and there).
Use ApiControllers When - If you want to provide a data driven/REST-ful interface to a system.

No comments:

Followers

Link