Wednesday, December 5, 2012

ASP.NET MVC - The Controller

As the name suggests the Controller is the one which controls the execution of the entire application, all requests to the applications are handled by the controller, once the controller receives the request it decided the model to be called, and the View to be invoked to render the output to the Browser.

A Model is a .vb or .cs class, Controller classes should end with the word “Controller” example EmployeeController, DepartmentController etc. The controller contains a set of Action methods, each of which is mapped to a specific request from the user.

// Action method for Initial request to load the Login Page
public ActionResult LogOn()
{
            return View();
}

// Action method for the Post request to handle the login request from the user.
[HttpPost]
public ActionResult LogOn(LogOnModel model)
{
          // Logic to handle the data entered by the user
}

Any URL in an Asp.Net MVC application should point to a controller, with appropriate parameters.


Search Flipkart Products:
Flipkart.com

No comments: