ASP.Net MVC Framework Introduction

ASP.NET MVC framework Overview

Objective

This tutorial will explain basically, how to work with ASP.NET MVC Frame work. I will explain that in chronic fashion. It would come in different parts.

Objective of PART 1:

Here I am going to introduce, what is MVC Design pattern. What are the advantages of using ASP.NET MVCF Framework?

MVC Pattern

The MVC pattern helps to create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements. The pattern specifies where each kind of logic should be located in the application. The separation helps to manage complexity.

As written at MSDN


The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model: The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View: The view manages the display of information.

Controller: The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

Structural relationship between the three objects.


According to Martin Flower

Following this principle leads to several good results. First, this presentation code [View] separates the code into different areas of complexity. Any successful presentation requires a fair bit of programming, and the complexity inherent in that presentation differs in style from the domain [Model] with which you work. Often it uses libraries that are only relevant to that presentation. A clear separation lets you concentrate on each aspect of the problem separately—and one complicated thing at a time is enough. It also lets different people work on the separate pieces, which is useful when people want to hone more specialized skills.

So MVC components could be summarized as follows

Model: This component implements logic of the application data domain.

View: This component displays user interface. UI get created from Model data.

Controller: This component handles user interaction. It controls user input to display information on View from Model.


Pictorially operations in MVC framework could be shown as


ASP.NET MVC Frame Work

The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications.

The ASP.NET MVC framework offers the following advantages

  • It makes it easier to manage complexity by dividing an application into the model, the view, and the controller.
  • 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.
  • It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure. F
  • It provides better support for test-driven development (TDD).
  • It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior.

Features of ASP.NET MVC Framework

  1. Separation of application task and testability and test driven development by default.
  2. Any Unit test framework which is compatible with ASP.NET can be used for testing.
  3. It is a pluggable framework. Any component can be easily replaced or designed or customized.
  4. It supports uses of Dependency Injection and Inversion of Control Framework like UNITY.
  5. It supports URL naming pattern that work well for Search Engine Optimization (SEO) and Representational state transfer (REST) addressing.
  6. It supports existing ASP.NET features.
  7. It supports of using markup in existing .ASPX pages.

 

How to Start with ASP.NET MVC Frame work?

Step 1

If ASP.NET MVC Frame Work Project template is installed on machine then we could select it as

File-> New-> Project->Web-> ASP.NET MVC web Application. If Project template is not installed it download it
http://www.pnpguidance.net/Category/ASPNETMVCFramework.aspx


Step 2

Select as per requirement, whether to create Unit test project or not.


Step 3

After creating Solution explorer will contain following folders.


 

 

Step 4

Run this Sample project. Following page will get display in browser.


This is a running ASP.NET MVC application.

URL and Page Mapping


There is no one to one relationship between page and URL in ASP.NET MVC web application.


Note: I will continue this article in next part. This is Part 1 and here I am explaining Introduction of MVC Design pattern and ASP.NET MVC Frame work.

Happy Coding

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s