While explaining routing in MVC 4, I have explained that Controller is responsible for returning a response based on the request. Also the first call will always go to controller in MVC. The base class of the controller is ControllerBase, which will provide all the MVC handling. Controller is responsible for the following:
- Responsible to call appropriate action method and validate it can be called.
- Process the logic.
- Error handling.
- Providing the default WebFormViewEngine class for rendering ASP.NET page types (views).


Note: All controller classes must be named using the "Controller" suffix.
Now just look at the following code which got generated after adding a new “HomeController”.
- namespace MvcApplication1.Controllers
- {
- public class HomeController: Controller
- {
- //
- // GET: /Home/
- public ActionResult Index()
- {
- return View();
- }
- }
- }
Under the controller we use to write the “Action Methods," which are bound with the logic to process the request and will generate the response accordingly. Based on the routing configuration defined in “Global.asax” file,
Now let see how actions methods work based on Route:
- https://www.yoursite.com
- https://www.yoursite.com/Employee
- https://www.yoursite.com/Employee/GetDetails
- https://www.yoursite.com/Employee/GetDetails/720501
ASP.NET MVC ActionResult:
There are various types of action results available in MVC 4. When a new controller gets created one or more action result will come by default. In MVC most of the action method returns a View which is an instance of ViewResult class.
ActionResult | Helper Method | Description |
ViewResult | View | Renders a view as a web page |
PartialViewResult | PartialView | Renders a partial view, which defines a section of a view that can be rendered inside another view. |
RedirectResult | Redirect | Redirect to another action method |
RedirectToRouteResult | RedirectToRoute | Redirect to another action method |
ContentResult | Content | Returns a user-defined content type |
JsonResult | Json | Returns a serialized JSON object |
JavaScriptResult | JavaScript | Returns a script that can be executed on the client |
FileResult | File | Returns a binary output to write to the response |
EmptyResult | (None) | Returns a null result |

Nishant MittalPosted Jan 18, 2016, 12:54 AM
Thanks Jaco :)
Jaco ZwartsPosted Jan 18, 2016, 12:42 AM
Nice this helped me alot seeing that im new to MVC
Nishant MittalPosted Jan 17, 2016, 11:15 PM
Thanks Guys
Santhakumar MunuswamyPosted Jan 17, 2016, 2:26 PM
Thanks for nice share
Pradeep SahooPosted Jan 16, 2016, 11:28 PM
Thanks for sharing
Ankur MistryPosted Jan 16, 2016, 1:18 PM
Helpful, thanks for sharing
Shubham KumarPosted Jan 16, 2016, 12:52 PM
nice
Nishant MittalPosted Jan 15, 2016, 9:24 AM
Thanks sir
Debasis SahaPosted Jan 15, 2016, 8:31 AM
Nice one..