CODEDIGEST
Home » Articles
Search
 

Technologies
 

Sponsored links
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
Beginning ASP.NET MVC Framework – PART I

By Gaurav Arora
Posted On Mar 27,2009
Article Rating:
Average Rating: 5
No of Ratings: 1
No of Comments: 0
Category: ASP.Net MVC
Print this article.

Beginning ASP.NET MVC Framework – PART I


History

ASP.NET MVC, Microsoft launched framework to build Model View Controller applications for ASP.NET.  After releasing series of beta version, the full version is available here.


Introduction

The MVC pattern separates the components of an MVC web application, which allows the more controls of the individual parts of that application.

MVC is a standard design pattern that many developers are familiar with.

Some types of Web applications will benefit from the MVC framework. Others will continue to use the traditional ASP.NET application pattern that is based on Web Forms and postbacks. Other types of Web applications will combine the two approaches; neither approach excludes the other.


MVC pattern separates objects into following three important sections:

 

Ø      Model: This section is specially for maintaining data. It is actually where business logic, querying database, database connections etc. implemented.

 

Ø      View: Displaying all or some portion of data or probably different view of data. View is responsible for look and feel, sorting, formatting etc.


Ø       Controllers: They are event handling sections which affect either the model or the view. In an MVC application, 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.


The MVC pattern helps you 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 UI logic belongs in the view. Input logic belongs in the controller. Business logic belongs in the model. This separation helps you manage complexity when you build an application, because it enables you to focus on one aspect of the implementation at a time. For example, you can focus on the view without depending on the business logic.



Features of the ASP.NET MVC Framework

The ASP.NET MVC framework provides the following features:

Ø       Separation of application tasks.

Ø       This is an extensible framework, easily to be customized.

Ø       Rigid support with all Asp.Net pages

Next section, we will see some of the prerequisites required to start ASP.Net MVC application.



An introductory example

Before we start learning how to create an MVC application, must need to know what the basic requirements to run the same are:




If you don’t own Visual Studio 2008, then you can download a 90 day trial version of Visual Studio 2008 from this website:
http://msdn.microsoft.com/en-us/vs2008/products/cc268305.aspx   


Alternatively, you can create ASP.NET MVC applications with Visual Web Developer Express 2008. If you decide to use Visual Web Developer Express then you must have Service Pack 1 installed. You can download Visual Web Developer 2008 Express with Service Pack 1 from this website:
http://www.microsoft.com/downloads/details.aspx?FamilyId=BDB6391C-05CA-4036-9154-6DF4F6DEBD14&displaylang=en  


After you install either Visual Studio 2008 or Visual Web Developer 2008, you need to install the ASP.NET MVC framework. You can download the ASP.NET MVC framework from the following website:

http://www.asp.net/mvc/  



Create a new ASP.NET MVC Application

Now, let’s know how to create a new MVC project:

Ø       Start your Visual Studio2008 : Start ->Programs -> Visual Studio2008

Ø       On the File menu, click New Project.

Ø       In the upper-right corner, make sure that .NET Framework 3.5 is selected.

Ø       Under Project types, expand either Visual Basic or Visual C#, and then click Web [I have opted C#]

Ø       Under Visual Studio installed templates, select ASP.NET MVC Web Application.

Ø       In the Name box, enter MVCApplicationStepAhead.

Ø       In the Location box, enter a name for the project folder.

Ø       If you want the name of the solution to differ from the project name, enter a name for the solution in the Solution Name box.

Ø       Select Create directory for solution and click OK

Select Yes, create a unit test project if Unit Test Project dialog box is displayed.

The above creates a new ASP.Net MVC project.

In next article we will explore the above example in more details.

 

Similar Articles
You can contribute to CodeDiget.Com:
Donate to CodeDigest.com
Article Feedback
Comments