We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Saturday, September 19, 2015

ASP.NET MVC Framework

The ASP.NET MVC framework is not a substitute for the ASP.NET web forms pattern. It just provides an alter choice to the developer while designing and developing a web application.
The MVC framework resides inside the system.web.mvc namespace. We already know system.web is used for asp.net web application. MVC namespace is the part of this namespace.
MVC framework consists of the following components.

  • Model
  • View
  • Controller
 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 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 functions independently of the view and the controller layers. 
  • For performing any task, the view and controller interact with the model.
Example:-
    Suppose, we want to calculate the area of the rectangle. then the computational part will be performed in the model layer. 
View In MVC Framework:-  
The view provides the user interface (UI) for the model. We already know, the user interacts with an application through view (GUI). 
There are some functions of view in an  asp.net MVC application.
  • Rendering the content of the model:- The main work (function) of the view is to represent the information in a user understandable format. With the help of view, the user can perform input-output operations.
  • Requesting the updates from the model:- We already know, the data access and business layer codes available on the model layer. So any changes in database or values in the model layer to update the changes if any.
  • Sending the user inputs to the controller:- Suppose, if the user wants to modify the database value on the model layer, in such case user can't communicate with the model layer directly. Here user first interacts with a view which further communicates with the controller about the user input, after that controller makes changes in the model layer according to user requirements and then after it informs the changes to the 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.
 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 is some functionality of the controller in the MVC Framework.
  •  Control the data transmission between the 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 a mediator 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 the model layer.   
  • Select an appropriate view for response:- An application provides multiple views of an application. The controller layer is helpful to select the most appropriate view and delivers it to the user.
Working of ASP.NET MVC Application:-
Here I Will Show We, 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 provided 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 the access of the model is not required then send the data to the view layer.
  3. If access of the model is required then the controller sends the request to the model layer.
  4. All computation process occurs on the model layer. after that model notify the changes to the 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.

No comments: