Monday 30 June 2008

Routing and DynamicData

*** I've pulled this after what David Ebbo said in the this thread Re: Manual Scaffolding and Routing with Compound PK's until I really understand what I'm talking about ***

Some useful links regarding Routing:

Mike Ormond's using ASP.NET Routing independent of MVC

Ian Blackburn's passing of parameters to the aspx page



Anonymous said...

Hi Steve,

Just a question, it seems like you are the foremost expert on dynamic data as I have run across your blog many times. Your solutions are just wonderful!

I am using Dynamic Data 3.5 with Entities

My questions is...

I want to create a new PageTempalte called


that a few of my entity tables will use for the list action as opposed to the List.aspx page that is already there. The remaining entity tables will continue to use the List.aspx page.

I know I can create a subfolder for each of my entities in CustomPages and create a copy of List.aspx under each one. But this will cause me to maintain multiple custom List.aspx pages when really all I need is one.

I was thinking I could alter the ListActionPath liek this:

// remove tables from the list if DenyRead
foreach (var table in MetaModel.Default.Tables)


Then create a route. But this does not work.

Can you offer any suggestions?

Stephen J. Naughton said...

You should use a route like:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
Constraints = new RouteValueDictionary(new { action = "List" }),
Table = "Table1|Table2|Table3",
Model = model

This will do the trick.