What is the difference between a Web API controller and an MVC controller?
Quick Answer
An MVC controller derives from Controller and typically returns a view (HTML) via view/model. A Web API controller derives from ControllerBase, is marked [ApiController], and returns data that is serialised (usually JSON) through content negotiation. In ASP.NET Core they are the same framework — the difference is base class, the [ApiController] conveniences, and what the action returns.
In ASP.NET Core they're the same framework now — it's not two stacks like it was in the old days. An MVC controller inherits from Controller and returns a view, so it has all the view and TempData helpers. An API controller inherits from ControllerBase, which drops the view stuff but keeps model binding and helpers like Ok and NotFound, and you put [ApiController] on it. That attribute is the real convenience — it auto-returns a 400 with problem details when ModelState is invalid, infers [FromBody] for complex parameters, and requires attribute routing. The API returns data that gets serialised through content negotiation, usually to JSON.
In classic ASP.NET they were genuinely separate stacks (System.Web.Mvc vs System.Web.Http). In ASP.NET Core they are unified:
Controller— adds view support (View(),ViewBag,TempData, view lookups). Use for server-rendered pages.ControllerBase— no view helpers; hasOk(),NotFound(),CreatedAtAction(), model binding,User. Use for APIs.[ApiController]adds: automatic400on invalidModelState, binding-source inference ([FromBody]for complex types),ProblemDetailserror responses, and attribute routing requirement.
Content negotiation — a Web API looks at the Accept header and picks a formatter (JSON by default, XML if configured). An MVC action just renders the view it names.