ASP.NET MVC is a new web application framework from Microsoft.MVC stands for Model-View-Controller, It is a framework for building web applications using a "Model View Controller" design. ASP.NET MVC is an alternative and a complement to Web Forms, which means you won’t be dealing with pages and controls, postbacks or view state, or complicated ASP.NET event life cycle.
MVC Architecture
Image Source -Google
Model: Model is a business entity on which the overall application operates. It is the lowest level of the pattern which is responsible for maintaining data. We don't need to specify the DAL (Data Access Layer) with MVC for small code application instead of DAL we directly create DAL code in Model class.
View: It represents the presentation layer of the application It is responsible for providing User-Interface to the User.
Controller: Controller is heart of MVC Achitecture.It handles a request from a view and updates the model that results a change in Model’s state. The controller acts as a coordinator between the Model and the View.
MVC Request Life Cycle
Image Source -Google
An MVC application has different architecture, structure, and page processing than a web form. In an ASP.NET application, requests are handled by ASP.NET; i.e., ASP.NET calls the page, executes the events, and then returns the response. But in MVC, we have to write the models, create the views and code the controllers. In MVC, requests are handled by UrlRoutingModule HttpModule. This module parses the request, selects a route (we will talk about routing later) based on the configuration which we will provide. Then request is routed to one of the controllers that we write. Then, it is the controller’s responsibility to access the database through Models and provide the response to UI through Views. Thus, we have our control on requests and response. So, in MVC, nothing is hidden from us. We have to code more in MVC as there is nothing automatic.
Conclusion
After Understanding the whole concepts now we are able to know why and where to use MVC, in another part of learning MVC we’ll be creating a MVC application from scratch, exploring the practical implementation of MVC.
0 comments:
Post a Comment