Understanding the ASP.NET MVC Framework Pattern

In high-level terms, the MVC pattern means that an MVC application will be split into at least three pieces:

  • Models, which contain or represent the data that users work with. These can be simple view models, which just represent data being transferred between views and controllers; or they can be domain models, which contain the data in a business domain as well as the operations, transformations, and rules for manipulating that data.
  • Views, which are used to render some part of the model as a user interface.
  • Controllers, which process incoming requests, perform operations on the model,and select views to render to the user.

Models are the definition of the universe your application works in. In a banking application, for
example, the model represents everything in the bank that the application supports, such as accounts, the general ledger, and credit limits for customers as well as the operations that can be used to manipulate the data in the model, such as depositing funds and making withdrawals from the accounts.
The model is also responsible for preserving the overall state and consistency of the data. For example, making sure that all transactions are added to the ledger, and that a client doesn’t withdraw more money than he is entitled to or more money than the bank has.

Models are also defined by what they are not responsible for: models don’t deal with rendering UIs or processing requests. Those are the responsibilities of views and controllers. Views contain the logic required to display elements of the model to the user and nothing more. They have no direct awareness of the model and do not directly communicate with the model in any way.  
Controllers are the bridge between views and the model. The requests come in from the client and are serviced by the controller, which selects an appropriate view to show the user and, if required, an appropriate operation to perform on the model.

Each piece of the MVC architecture is well-defined and self-contained. This is referred to as the
separation of concerns. The logic that manipulates the data in the model is contained only in the model; the logic that displays data is only in the view, and the code that handles user requests and input is contained only in the controller. With a clear division between each of the pieces, your application will be easier to maintain and extend over its lifetime, no matter how large it becomes.


The interactions in an MVC application


By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Popular posts from this blog

How to create zip file to download in JSP- Servlet

How to create DataGrid or GridView in JSP - Servlet

Pinging in ASP.NET Example