FREE BOOK
Chapter 2: Your First ASP.NET MVC Application
This chapter describes the ASP.NET MVC project template that is installed in Visual Studio. A simple application is built, briefly touching on all of the aspects of the ASP.NET MVC framework.
Your First ASP.NET MVC Application
When downloading and installing the ASP.NET MVC framework SDK, a new project template is installed in Visual Studio-the ASP.NET MVC project template. This chapter describes how to use this template. We will briefly touch all aspects of ASP.NET MVC by creating a new ASP.NET MVC web application based on this Visual Studio template. Besides view, controller, and model, new concepts including ViewData-a means of transferring data between controller and view, routing-the link between a web browser URL and a specific action method inside a controller, and unit testing of a controller are also illustrated in this chapter.
In this chapter, you will:
- Receive an overview of all of the aspects of an ASP.NET MVC web application
- Explore the ASP.NET MVC web application project template that is installed in Visual Studio 2008
- Create a first action method and a corresponding view
- Create a strong-typed view
- Learn how a controller action method can pass strong-typed ViewData to the view
- Learn what unit testing is all about, and why it should be performed
- Learn how to create a unit test for an action method by using Visual Studio's unit test generation wizard and modifying the unit test code by hand