ASP.NET MVC Framework Real concepts

The ASP.NET MVC framework is not a substitute for the ASP.NET web forms pattern.It just provide an alter choice to the developer while designing and developing a web application.
The MVC framework resides inside the system.web.mvc namespace. You already know system.web is used for web application. MVC namespace is the part of this namespace.
MVC framework consists of the following components.
  • Model
  • View
  • Controller
Now we will discuss each in detail with an example.

1.) Model in MVC Framework :-  
  • This component represents the data and the business logic of the application.The model in the MVC framework is not related to the presentation of the application.
  • The model component focus on keeping track of the state of the application.
  • This component (model) is not exposed to the information about the view and the manner (way) in which data is to be displayed.
  • A model does not know about view actions used to manipulate the data.
  • Every data is accessed and manipulated through the methods that are completely independent of the view.
  • A model is contains the business logic and data access code .This is the main component of the MVC framework.
  • A model defines what the application exactly does.
  • The model layer is self contained and function independent of the view and the controller layers. 
  • For performing any task , the view and controller interact with model.
Example :-
    Suppose,we want to calculate the area of the rectangle.then the computational part will be performed in the model layer. 

    2.) View in MVC Framework :-  
    The view provides the user interface (UI) for the model.You already know ,the user interacts with  an application through view (GUI) . 
    There are some functions of view in an MVC application.
    • Rendering the content of the model :- The main work (function) of the view is represent the information in user understandable format.With the help of view user can perform input output operations.
    • Requesting the updates from the model:- You already know ,the data access and business layer codes available on the model layer.So any changes in database or values in model layer to update the changes if any.
    • Sending the user inputs to the controller :- Suppose, if user want to modify the database value on the model layer,in such case user can't communicate with model layer directly .Here user first interact with view which further communicates with controller about the user input,after that controller makes changes in model layer according to user requirements and then after it inform the changes to view layer.
    • Allowing the controller to select the view:- Different users might have different views.Views allows the controller to determine which view is suitable for which user and provide them accordingly.
    3.) Controller in MVC Framework :- 
    Controller act as a mediator between view and model. When the user interacts with  the view and tries to update the model,the controller calls (invokes) methods to update the model.
    There are some functionality of controller in MVC Framework.
    •  Control the data transmission between model and view layer:-The controller control the data flow  and transformation between the model and the view layer in the application.
    • Mapping the user action into model updates:- The controller is used as immediator between view and model layer.If any users want to modify the database values through view ,here user can't communicate directly through view to model layer.   
    • Select appropriate view for response:- An application provides multiple views of an application.The controller layer is helpful to selects the most appropriate view and delivers it to the user.
    Working of ASP.NET MVC Application :-
    Here i will show you, how does your MVC application work.

    There are some steps of working of any MVC Application as given below:-

    1. The client sends a request through a UI provide by the view,which further passes this request to the controller.
    2. The controller receives the input request coming from the client side through the interface provides by the view, controller process the request ,if access of model is not required then send the data to the view layer.
    3. If  access of model is required then controller send the request to model layer.
    4. All computation process occurs on model layer. after that model notify the changes to view layer.
    5. The controller then selects the new views to be displayed.
    6. The view presents a UI according to the model.
    7.  The view data is also contained within the model .View queries about the state of the model to show the current data.


    Post a Comment

    Powered by Blogger.