views:

257

answers:

1

In the default Visual Studio template for a dynamic data web application, Global.asax includes the following two sample routes.

// route #1
routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
    Action = PageAction.List,
    ViewName = "ListDetails",
    Model = model
});

// route #2
routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx") {
    Action = PageAction.Details,
    ViewName = "ListDetails",
    Model = model
});

They only differ by the Action property. The comments in Global.asax indicate the two routes are used to configure a single page that handles all CRUD behaviors.

Why is route #2 is necessary? Does it do anything? ListDetails.aspx does not look at the Action property of the route. It seems that everything runs fine when I comment out route #2 and I only have route #1 in Global.asax. Route #2 looks like its not used.

+2  A: 

You're right, route #2 isn't going to be used in this instance. The only time route #2 would come into play is if you were requesting a details page URL from the route engine. Because the ListDetails.aspx page template handles both the list and details views, it never requests a details template URL.

LostInTangent