Ron Ron - 1 year ago 116
ASP.NET (C#) Question

Web Api vs MVC Controller

We had a discussion at work where one of our employees was creating a Web Api controller specifically for one method that returns JSON data. While it works, I noted the fact that he didn't have to create a Web Api controller for this since the scope of that data is really only to be used in that application and not to be consumed elsewhere. I mentioned that he should have just put a JsonResult method in the already existing controller and that now we have two controllers to maintain instead of one. That's when the chairs went flying!!!

While I don't think my suggestion is wrong maybe it is. Am I wrong in my thought process.

Win Win
Answer Source

It is an opinion based question, so take my answer with a grain of salt.

If this is all just for a single action method, my opinion is not worth to have a separate API Controller.


  1. You need to register route for Web API.
  2. You need to register Web API controller for Dependency Injection.
  3. You need separate Exception Handler.
  4. You need separate Filters for Web API.

1 and 2 are quite easy, but 4 is not if you have too many filters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download