You seem to be confused about things here. There's really no such things as MVC or Web API when it comes to ASP.NET Core. A controller is a controller is a controller. That said, since ASP.NET Core 2.1, "API" controllers generally now inherit from ControllerBase
and have an ApiController
attribute applied, while "MVC" controllers inherit from Controller
. However, that's only the case because if a controller is being used specifically for API stuff, it doesn't necessarily need all the bells and whistles of Controller
and the ApiController
attribute adds some helpful features specific to APIs. You could just as well have an "API" controller that inherited from Controller
without the ApiController
attribute, or you could even have an "MVC" controller inherit from ControllerBase
.
Long and short, the terms are mere semantics. Calling a controller an "API controller" is shorthand for saying that it's a controller that conforms to REST specifications and has actions that return something like JSON or XML, whereas calling a controller an "MVC controller" is just shorthand for saying that it's a controller whose actions return Razor views.
That said, the Twilio docs actually have you using a TwilioController
, which while I haven't dug into the source is likely just derived from ControllerBase
and implements the webhook handling boilerplate for you. As such, if your question is why you cannot use just plain Controller
or ControllerBase
here instead of TwilioController
, the answer is likely that you can if you implement the same code that it does yourself.