I am a bit confused in the real need of web Api Controller. MVC Controller can do almost everything which a web Api Controller does? Can anybody please help me to understand why web Api can be needed and what type of scenarios in which we can't use MVC Controller Actions? Thanks in advance for your help.
Asked
Active
Viewed 633 times
0

iAM
- 1,365
- 15
- 25

Raz Muhammad
- 11
- 3
-
Possible duplicate of [Difference between MVC 5 Project and Web Api Project](http://stackoverflow.com/questions/22589245/difference-between-mvc-5-project-and-web-api-project) – Nasreddine Jan 15 '17 at 10:35
-
Thanks bro, I almost got my answer from the shared link . thanks for your prompt support – Raz Muhammad Jan 15 '17 at 10:39
-
2Possible duplicate of [Difference between ApiController and Controller in ASP.NET MVC](http://stackoverflow.com/questions/9494966/difference-between-apicontroller-and-controller-in-asp-net-mvc) – iAM Jan 15 '17 at 10:43
1 Answers
0
Short answer as answered by Andre Loker is:
Use Controller to render your normal views. ApiController action only return data that is serialized and sent to the client.
-
-
but one more thing , data can be returned from controller actions as well and even in serialized form also so if we have that facility then why we need apiController specifically ?. – Raz Muhammad Jan 15 '17 at 10:46
-
-
When talking about data, MVC controller returns data only in JSON format by returning `JsonResult` while API controller can return data in different formats JSON, XML... and you dont have to worry about returned data type as API Controller will figure it out based on Accept header content type in the request. – iAM Jan 15 '17 at 11:32