Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Thursday, March 24, 2016

What is ActionResult in ASP.Net MVC


ActionResult is return type of a controller method in MVC.




public ActionResult Index()

        {

            return Content(DateTime.Now.ToString());



        }



Below are different response types which can be sent to the view via ActionResult:-

ViewResult - Renders a specified view to the response stream

EmptyResult - An empty response is returned

PartialViewResult - Renders a specified partial view to the response stream

FileContentResult - Returns a file to the client

RedirectResult - Performs an HTTP redirection to a specified URL

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

JsonResult - Serializes a given object to JSON format

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

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

FileStreamResult - Returns a file to the client, which is provided by a Stream

FilePathResult - Returns a file to the client

0 comments:

Post a Comment