•Models encapsulate objects and data
•Views generate the user interface
•Controllers interact with user actions
MVC based application development is bundle of ASP.NET shared features ( Configuration , Authentication , Membership and Roles , State Management , Caching ) with Javascript, jQuery and some of classic ASP features.
When user send an request from browser in the view, it triggers the corresponding action in the controller that performs actions using underlying model and model interact database sends back required info to controller, which in return data(after performing various business rules and actions) through view to the user.
In MVC, processing of user requests is not file based as in asp.net, the processing happens based on actions. Like when user submit data in a login form, mvc triggers “Login” action(method) in a controller rather than “Loginpage.aspx” as in asp.net. Action in a controller is nothing but a method. Controller is a class to handle user actions and map to corresponding action methods.
The ASP.NET MVC framework maps URLs to classes that are referred to as controllers. Controllers process incoming requests, handle user input and interactions, and execute appropriate application logic. A controller class typically calls a separate view component to generate the HTML markup for the request.
The base class for all controllers is the ControllerBase class, which provides general MVC handling. The Controller class inherits from ControllerBase and is the default implement of a controller.
All controller classes must be named by using the “Controller” suffix
When a user enters a URL into the browser, the MVC application uses routing rules that are defined in the Global.asax file to parse the URL and to determine the path of the controller. The controller then determines the appropriate action method to handle the request. By default, the URL of a request is treated as a sub-path that includes the controller name followed by the action name.
Controllers can include as many action methods as needed.
Action methods typically have a one-to-one mapping with user interactions. Examples of user interactions include entering a URL into the browser, clicking a link, and submitting a form. Each of these user interactions causes a request to be sent to the server. In each case, the URL of the request includes information that the MVC framework uses to invoke an action method.
Most action methods return an instance of a class that derives from ActionResult. The ActionResult class is the base for all action results. However, there are different action result types, depending on the task that the action method is performing. For example, the most common action is to call the View method. The View method returns an instance of the ViewResult class, which is derived from ActionResult.
You can create action methods that return an object of any type, such as a string, an integer, or a Boolean value. These return types are wrapped in an appropriate ActionResult type before they are rendered to the response stream.
Various ActionResule types are:
- ViewResul
- PartialViewResult
- RedirectResulteResul
- ContentResult
- JsonResult
- JavascriptResult
- FileResult
- EmptyResult