Skip to Main Content
ASP.NET 4 24-Hour Trainer
book

ASP.NET 4 24-Hour Trainer

by Toi B. Wright
July 2010
Beginner content levelBeginner
552 pages
10h 14m
English
Wrox
Content preview from ASP.NET 4 24-Hour Trainer

Chapter 8B. The Request Life Cycle in MVC

Every time a page is requested using the ASP.NET MVC framework, it must complete a request life cycle. In this lesson I describe the steps in a page's request life cycle.

ROUTING

This is a sample URL that is used to request a page using the ASP.NET MVC framework (see Figure 8B-1):

http://localhost:1585/Home/About

FIGURE 8B-1

Figure 8B.1. FIGURE 8B-1

Notice that the URL does not refer to a specific page. Instead, the ASP.NET MVC framework uses a routing table to determine how the request should be handled. When you create an MVC application, routing is automatically enabled in the Global.asax.cs file.

This is the routing information included in the Global.asax.cs file that is used by the sample MVC application that you created in the previous lesson:

routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL with parameters
    new { controller = "Home", action = "Index", id = "" }  // Defaults
);

The route is used to determine which controller and action should be used to process the request. When the "Default" route is applied to the following request the route dictates that the HomeController should be used with the About action. See Figure 8B-2.

FIGURE 8B-2

Figure 8B.2. FIGURE 8B-2

Note

The word Controller is automatically added to the name of the controller. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 4 24-Hour Trainer

ASP.NET 4 24-Hour Trainer

Toi B. Wright
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470596913Purchase bookExamplesErrata