What is the difference between ApiController and Controller?

Technology CommunityCategory: ASP.NET Web APIWhat is the difference between ApiController and Controller?
VietMX Staff asked 3 years ago
  • Use Controller to render your normal views.
  • ApiController action only return data that is serialized and sent to the client.

Consider:

public class TweetsController : Controller {
  // GET: /Tweets/
  [HttpGet]
  public ActionResult Index() {
    return Json(Twitter.GetTweets(), JsonRequestBehavior.AllowGet);
  }
}

or

public class TweetsController : ApiController {
  // GET: /Api/Tweets/
  public List<Tweet> Get() {
    return Twitter.GetTweets();
  }
}