Action Results in the controllers MVC4

Saratvaddilli
Posted by in ASP.NET MVC category on for Beginner level | Points: 250 | Views : 17475 red flag

When ever we create a controller .By default we will get an action result method .We have different types action results .Let us have an overview of available action results and where to use appropriate action result

Introduction

Let us see the available action results in the controllers Asp.Net MVC 4 


Controllers 

   
  Controllers are nothing but the classes that are inherited from a base class called as controller . Controller serves the web request first , so when ever a request has been made from the user (EX: To view the data ,download the file ) , controller should respond for it i.e it should send the data the UI . To send the requested data we need some entity right ? . Here  in Controllers we had an entity called action result.

   They are different types of action results .
        

ViewResult 


   This is the most common type of action result , that returns a view which is responsible for rendering html content to the browser 

PartialViewResult 


    This is same as view type but it can be used in some other views also .

Redirect Result 


    Redirect to the user to another URL (With in the same/Different applications )    
 

RedirectToRouteResult 


    Redirect the user to another action method not to the URL 

ContentResult 


   This is used to return any type of  content (i.e irrespective of datatype) .But we have to specify the content data type .By default it was string type

JsonResult 


     This is used to return Json Object .
 

JavaScriptResult 


  This is used when ever user wants to send the java script data object .


File Result

 
  This is used when we want to show the file / download the file 

EmptyResult


  This is equal to a return type void .

Conclusion


  We had a clear information regarding Action Results , in the coming articles lets dig on individual action result with an example  

Reference


http://msdn.microsoft.com/en-in/library/dd410269(v=vs.98).aspx

Page copy protected against web site content infringement by Copyscape

About the Author

Saratvaddilli
Full Name: vaddilli sarat
Member Level: Bronze
Member Status: Member,MVP
Member Since: 7/30/2012 3:54:23 AM
Country: India
Thanks and Regards V.SaratChand Show difficulties that how difficult you are
www.dotnetfunda.com
I am sarat vaddilli working on the cutting edge technologies like html5,css3, Jquery and MicroSoft technologies like Asp.Net,Asp.Net MVC, SQL Server.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)