freePRnow.com Plans | Login    

Author Details
Krishan Singh
dotnet360.in@gmail.com
dotnet360.in

Free learning asp.net, c#.net, ado.net, wcf services, web services, Jquery, Javascript, Html, Interv


Getting Started With MVC, MVC framework, structure of mvc, pattern of mvc

freePRnow.com, 2/07/2015 - The Microsoft ASP.NET model-view-controller (MVC) represents an alternative architecture to the standard ASP.NET web form model. This alternative is based on the common MVC software design pattern that separates the layers of your website into user interface (view), data and business logic (model), and input handling (controller). This separation through MVC results in loosely coupled objects that are highly testable, can be developed independently from one another, and offer granular control of your application code. ASP.NET MVC is not meant to replace web forms; it is simply an alternative you can take advantage of based on your specific needs. In fact, you can combine both models in a single website

Architecture of MVC.

An ASP.NET MVC application has a different architecture, page processing model, conventions, and project structure than an ASP.NET web form site. Requests to an ASP.NET MVC application are handled by the UrlRoutingModule HttpModule. This module parses the request and selects a route for that request based on a configuration that you define. Ultimately, the request is routed to one of the many controller classes that you write to manage request processing. It is the selected controller’s job to access your data and business logic (the model), connect it for display (the view), and send the response back to the user. The controller handles all requests—view and updates (posts). This is considerably different than the basic architecture of an ASP.NET application, in which requests are handled by ASP.NET: it calls your page; it executes your events in order; those events affect the response; and ASP.NET ultimately returns the response. With ASP.NET MVC, you write the model, create the views, and code the controllers; thus you have finer control over how each request is handled and each response is rendered. With ASP.NET MVC, there is less “hidden” from you (and thus less work done automatically for you).

Figure-1 shows the high-level architecture of the components

you write to manage a request with ASP.NET MVC. As you can see, requests are routed to controllers. The controller works with the data model, selects a view (based on an action), and returns the results.

These components should be familiar to you as a web developer. A controller is a class; the model is either made up of custom classes or generated classes that use the Entity Framework or LINQ to SQL; and the views are ASPX webpages. The following list provides a more detailed definition of these components:

¦ Model The model is the data and related business logic or validation rules in your application. The model objects typically can retrieve, update, and add records to an underlying data store such as a Microsoft SQL Server database. A model can be a LINQ to SQL layer, an Entity Framework layer, or some other layer that provides access to your data and the business rules.

¦ View The view indicates how data from the model will be displayed. It is a set of webpages and user controls that define layout for model data based on user actions such as read, edit, and insert. For example, you might have a view that defines specific layout information for a page that allows a user to edit a Customer object from your model. View tasks do not include the input logic or the processing of user actions; these are managed inside the controller.

http://dotnet360.in/dotnet/details/getting-started-with-mvc

 

Plans | FAQs | Contact Us | Terms & Conditions | Privacy Policy