Controller is a Component to represent application logic , this logic will accept user request and it will interact with the model if required and provides data to view as per the client request.In general we can say that ,the controller in MVC architecture handles any incoming URL request. Controller is a class derived from the base class i.e ''System.Web.Mvc" . Controller class contains public methods called as "Action methods". Controller and it's Action Methods handles incoming browser request,retrieves necessary model data and returns appropriate responses.
Every controller class must be located under the "Controllers" folder of MVC folder structure.Every controller class name must end with a word "Controller" for e.g- Controller for "Home" must be "HomeController". Controller is responsible for many operations as follows,
- It is responsible for responding to user input such as button/hyper link click & keyboard and mouse operation.
- It is responsible to making changes to model in response to user input.
- It is responsible to load the relevant view to the user based on the user input.
Controller Class :-
You can create controller class by following below pattern.
- Any class need to act as a Controller should be inherited from the "controller" class.
- All the controller class should be placed inside the "Controllers" folder.
- Controller class name should be suffixed with "Controller" e.g homeController.
- Controller class should have minimum one "Action Method".
No comments:
Post a Comment