Vijay Kumar
ASP.NET Web API Controller and ASP.NET MVC Controller

ASP.NET Web API
ApiControllers 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 MVC
MVC 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);} }

By Vijay Kumar in .NET on Nov 18 2019


Most Popular Job Functions


MOST LIKED QUESTIONS