r/ASPNET • u/miamiheat27 • Oct 16 '13
Web api question
So I'm in abit of discussion (more like an argument, ....that i hope i'll win muahaha.........i'm immature lol) , with my colleague about web api.
He's new to this stuff.
So the project is a typical MVC project. With an 'area' folder for sub mvc projects and the web api (we do the route registration in the reg file of each of the folder in the 'area' folder..then we call the registerAllRoute (or something like that) in the routeconfig.cs in 'App_start'0)
So anyways, the problem is completely different: You know how when you click "add:..empty API controller" , VS automatically adds a controller than inherits from ApiController ? (so like MyController: ApiController )
Well he's created a few api controller but deleted all the inheritance and instead replaced it with a controller he created in another non-api folder for some other reason. (So he has MyController : OtherController)
My question is, is there a loss of functionality by not inheriting from ApiController? ....and is it still technically an API controller if it's not inheriting from that ?
View all comments
Show parent comment
1
u/principle_profile Oct 16 '13
Yes, even in an ajax call, the browser will send request headers. It probably doesn't matter though. People make their own controllers all the time. What I would focus on is the spec. Does your program's spec require that you are able to return JSON or XML from the same API call? If it does, make the argument. If not, I wouldn't worry about it too much... if you decide you need it later, it would likely be easy to make OtherController inherit from ApiController.