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
Let us see the available action results in the controllers Asp.Net MVC 4
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 .
This is the most common type of action result , that returns a view which is responsible for rendering html content to the browser
This is same as view type but it can be used in some other views also .
Redirect to the user to another URL (With in the same/Different applications )
Redirect the user to another action method not to the URL
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
This is used to return Json Object .
This is used when ever user wants to send the java script data object .
This is used when we want to show the file / download the file
This is equal to a return type void .
We had a clear information regarding Action Results , in the coming articles lets dig on individual action result with an example