ASP.NET Web APIApiControllers are specialized in returning data.It take care of transparently serializing the data into the format requested by the client.Also they provide the functionality of HTTP Verbs to process the CRUD opertaion to perform in our application
The API controller returns the data in various formats, such as JSON, XML and other format based on the accept header of the request.The API controller supports content negotiation, self hosting.
public class HomeController : ApiController {// GET: /Api/Products/public List<ProductData> Get() {return Product.GetProducts();} }
ASP.NET MVCMVC Controller are specialized in returning view and data also.its always return the ActionResult type that specified in Controller class.The MVC returns the data in the JSON format by using JSONResult.The MVC can not supports content negotiation, self hosting.
public class HomeController : Controller {// GET: /Products/[HttpGet]public ActionResult Index() {return Json(Product.GetProducts(), JsonRequestBehavior.AllowGet);} }