subject: Mvc Framework [print this page] MVC (Model-View-Controller) is a architectural pattern which divide application into three main components and these components are as follow:-
(1)The Model
(2)The view
(3)The Controller
MVC Framework provides a new way to create asp.net web forms to MVC based web application.One of its great advantage is that it is integrate with existing asp.net features like master page concept,URL authorization, data caching, session, profile, and membership-based authentication also integrated. The asp.net MVC framework is a lightweight and also a highly testable presentation framework for web forms applications.The NameSpace where MVC framework is defined is in System.Web. Mvc which is supported part of System.Web namespace.
Now comes to explain you what MVC pattern is and how to use this with asp.net. MVC pattern helps us to create application which divide application in three part Inputlogic, Business Logic and UI Logic. And one more ting is that these are loose coupled in MVC framework. Here input logic belongs to the controller. UI logic belongs to view and last one business logic belongs to the model. And these three parts helps us to manage more complex application more easily because when we work on view we are not depend on the business logic.
Now I will explain three main components of MVC:-
(1)The Model:- Here Model objects are the parts of application that's helps to implement logic for our application data domain. We can also say Model in a MVC based application are the components of the application that are responsible for maintaining state. More often this state is persisted inside of a database. To under stand more clearly we take an example of product object which select information from database and then do a operation on it and then update information back to that table in SQL Serer database this is the work of Model. If our application is too small which only reads a dataset and sends this to view to display in this condition we doesn't have physical model layer. Here in this condition dataset takes the role of model object.
(2)The view:-Views components are used to display application user interface. And this UI is created form the model data.
(3)The Controller:-Controller are the components which handle user interaction and work with model and select a view to render that display UI,the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn queries the database by using the values.
Why To Use MVC:-
(1)One of the main advantage of MVC framework is that more complex application are divided into 3 parts Model, View and Controller which make it easy to create.
(2)MVC is highly extensible and plug-gable. Everything in the MVC framework is designed so that it can be easily replaced/customized
(3)MVC very helpful where team is too large which has large number of developers and web designers and team members need high degree of control.
(4)It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.
(5)MVC uses a Front Controller pattern that processes Web application requests but through a single controller. This enables you to design an application that supports a rich routing infrastructure.
(6)MVC has provides better support for TDD(test-driven development). We can also use unit testing in application without having to run the Controllers within an ASP.NET process.