ActionResult types in mvc

Types of action results

ActionResult Return Type


You can create action methods that return an object of any type, such as a string, an integer, or a Boolean value. These return types are wrapped in an appropriate ActionResult type before they are rendered to the response stream.
The following table shows the built-in action result types and the action helper methods that return them.

ActionResultHelper MethodDescription
ViewResultViewRenders a specifed view to the response stream
PartialViewResultPartialViewRenders a specifed partial view to the response stream
EmptyResult(None)An empty response is returned
RedirectResultRedirectPerforms an HTTP redirection to a specifed URL
RedirectToRouteResultRedirectToRoutePerforms an HTTP redirection to a URL that is determined by the routing engine, based on given route data
JsonResultJsonSerializes a given ViewData object to JSON format
JavaScriptResultJavaScriptReturns a piece of JavaScript code that can be executed on the client
ContentResultContentWrites content to the response stream without requiring a view
FileContentResultFileReturns a file to the client
FileStreamResultFileReturns a file to the client, which is provided by a Stream
FilePathResultFileReturns a file to the client

ActionResult types in mvc ActionResult types in mvc Reviewed by Bhaumik Patel on 8:26 PM Rating: 5