This article is only for learning purpose and to enhance the ASP.Net MVC skills.
With release of ASP.NET MVC Beta ,
MicroSoft launched tool / utility to build Model View Controller applications for ASP.NET. This is available at
1. ASP.NET MVC Beta .
2. ASP.NET MVC Beta Release .
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:
1. Model :
This section is specially for maintaining data. It is actually where business logic, querying database, database connections etc. implemented.
2. View :
Displaying all or some portion of data or probably different view of data. View is responsible for look and feel, sorting, formatting etc
3. 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:
1. Separation of application tasks.
2. This is an extensible framework, easily to be customized.
3. Rigid support with all Asp.Net pages
An introductory example:
Before we start learning how to create an MVC application , must need to know what are the basic requirements to run the same:
If you don't own Visual Studio 2008, then you can download a 90 day trial version of Visual Studio 2008 from this website:
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:
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:
Create a new ASP.NET MVC Application
Now, lets know how to create a new MVC project:
1. Start your Visual Studio2008 : Start ->Programs -> Visual Studio2008
2. On the File menu, click New Project.
3. In the upper-right corner, make sure that .NET Framework 3.5 is selected.
4. Under Project types, expand either Visual Basic or Visual C#, and then click Web [I have opted C#]
5. Under Visual Studio installed templates, select ASP.NET MVC Web Application.
6. In the Name box, enter MVCApplicationStepAhead.
7. In the Location box, enter a name for the project folder.
8. 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.
9. 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