Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications.

A Model View Controller pattern is made up of the following three parts: 1. Model - The lowest level of the pattern which is responsible for maintaining data. 2. View - This is responsible for displaying all or a portion of the data to the user. 3. Controller - Software Code that controls the interactions between the Model and View. MVC is popular as it isolates the application logic from the user interface layer and supports separation of concerns. Here the Controller receives all requests for the application and then works with the Model to prepare any data needed by the View. The View then uses the data prepared by the Controller to generate a final presentable response. The MVC abstraction can be graphically represented as follows.

The model
The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself.

The view
A presentation of data in a particular format, triggered by a controller's decision to present the data. They are script based templating systems like JSP, ASP, PHP and very easy to integrate with AJAX technology.

Web applications developed with ASP.NET MVC are even more SEO (Search Engine) friendly. it validates the input and then performs the business operation that modifies the state of the data model.NET MVC architecture is based on Microsoft .NET class 2.NET Framework 3. MVC model is basically a C# or VB.NET MVC is an architecture to develop ASP. MVC Interaction with Browser Like a normal web server interaction. A model can be used to pass data from Controller to view .NET Framework 3. ASP.NET MVC application requires Microsoft . The controller receives the input.NET web development. MVC application also accepts requests and responds to the web browser in the same way.5 and in addition uses LINQ to SQL Server. A model is accessible by both controller and view 3. Inside MVC Architecture The entire ASP. What is a Model? 1. Developing ASP. “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”.NET web applications in a different manner than the traditional ASP.The controller The controller is responsible for responding to user input and perform interactions on the data model objects.5 or higher.

controller 2. A view can use model to display data in page. 4. Controller is a heart of the entire MVC architecture 3.mvc. there must be 3 directories each for model. Inside the ROOT directory of the application. View is an ASPX page without having a code behind file All page specific HTML generation and formatting can be done inside view One can use Inline code (server tags ) to develop dynamic pages A request to view (ASPX page) can be made only from a controller’s action method What is a Controller? 1. 2.NET class which inherits system. 3.4. Controller can access and use model class to pass data to views 5. Inside Controller’s class action methods can be implemented which are responsible for responding to browser OR calling views. What is a View? 1. view and Controller. 4. Controller uses ViewData to pass any data to view MVC File Structure & File Naming Standards MVC uses a standard directory structure and file naming standards which are a very important part of MVC application development. . Controller is basically a C# or VB.

asax file in root folder.config ASP.NET MVC Execution Life Cycle Here is how MVC architecture executes the requests to browser and objects interactions with each other. and a web.NET application.asax o Web. there must have a Global.config like a traditional ASP. A step by step process is explained below [Refer to the figure as given below]: .  Root [directory] o Controller [directory]  Controller CS files o Models [directory]  Model CS files o Views [directory]  View aspx/ascx files o Global.Apart from 3 directories.

index() will happen inside MVC controller class. but MVC will only invoke the action method which has been parsed from the URL. So something like: homeController. . A controller class contains different action methods.asax – MVC routing (Step 2) The specified URL will first get parsed via application_start() method inside Global. So for [xyz. This is it. There can be more than one action]/home/index/:    Controller = home Action = index() ID = empty — we have not specified ID in [xyz. From the requested URL. so it will consider as empty string Controller and Action methods (Step 3) MVC now finds the home controller class in controller directory.aspx. Call to View (Step 4) Invoking view will return view(). it will parse the Controller.Browser Request (Step 1) Browser request happens with a specific URL. Action and ID. Let’s assume that the user enters URL like: [xyz. controller was home and action was index().com]/home/index/ Job of Global. Invoking action method can return plain text string OR rendered HTML by using view. So this is how MVC architecture works. In our case.asax file. A call to view will access the particular ASPX page inside the view directory and generate the rendered HTML from the ASPX and will respond back to the browser. its index() in our case. So calling view() will return a rendered HTML from the ASPX page located at /views/home/index. the whole process ends]/home/index/.

Sign up to vote on this title
UsefulNot useful