Saturday, August 11, 2012

ActionResult types available


ActionResult
The action result is a very generic return value for an action. This is because it is the abstract base class for other types of actions. It is actually a very simple class having only one method that needs implementing.



public abstract class ActionResult
{
    public abstract void 
        ExecuteResult(ControllerContext context);
}




Inheriting from the ActionResult are the following classes:

ContentResult
EmptyResult
FileResult
HttpStatusCodeResult
JavaScriptResult
RedirectResult
RedirectToRouteResult
ViewResultBase

These are the classes that inherit from ActionResult indirectly:

FileContentResult
FilePathResult
FileStreamResult
HttpNotFoundResult
HttpUnauthorizedResult
PartialViewResult
ViewResult


ActionResult is an abstract class that can have several subtypes:

a) ViewResult - Renders a specifed view to the response stream

b) PartialViewResult - Renders a specifed partial view to the response stream

c) EmptyResult - An empty response is returned

d) RedirectResult - Performs an HTTP redirection to a specifed URL

e) RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data

f) JsonResult - Serializes a given ViewData object to JSON format

g) JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client

h) ContentResult - Writes content to the response stream without requiring a view

i) FileContentResult - Returns a fle to the client

j) FileStreamResult - Returns a fle to the client, which is provided by a Stream

k) FilePathResult - Returns a fle to the client

No comments:

Post a Comment