Action Result Return Types in ASP.NET MVC

Action Result Helper Method Description
ViewResult View Renders a view as a Web page.


Return view for that action method: return View();

Return a different view: return View(“ViewName”);

PartialViewResult PartialView Renders a partial view, which defines a section of a view that can be rendered inside another view.
RedirectResult Redirect Redirects to another action method by using its URL.
RedirectToRouteResult RedirectToAction Or


Redirects to another action method.
ContentResult Content Returns a user defined content type.
Return a string: return Content(“A plain text”);
Return XML: return Content(“<node/>”,”text/xml”);
JsonResult Json Returns a serialized JSON object.
Return an object as JSON: return Json(player);
JavaScriptResult JavaScript Returns a script that can be executed on the client.
FileResult File Returns binary output to write to the response.
EmptyResult (None) Represents a return value that is used if the action method must return a null result (void).

Comments 1

Leave a Reply

Your email address will not be published. Required fields are marked *