OK I'll try to explain. the reason you have to move the file is if you create a custom page that is to be used with a particular table then the correct behavoir is to move it to the ~/DynamicData/CustomPage/TableName/Page.aspx this is the
default behavoir. DD routes always translate to the ~/DynamicData folder if there is a CustomePages folder for that table it will look there fist for the relavent page if not it will use a page from the PageTemplates folder.
OK so far.
Now if you have add a new route into the equasion it's still going to look at thing in the above way unless you make it clear in your route that the file is outside the ~/DynamicData folder.
So if I had a page ~/Articles.aspx (in the root) of the site I would not need to provide a route to acces this file unless I wanted to have the paramter slug passed in as part of the url:
~/Articles.aspx?slug=10
So if I wanted to have a url like:
~/Articles.aspx/10
or
~/Articles/10
the I could add my own route handler, because if you look at a route:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
{
Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
Model = model
});
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Routing question
Apr 03, 2009 09:15 AM|LINK
OK I'll try to explain. the reason you have to move the file is if you create a custom page that is to be used with a particular table then the correct behavoir is to move it to the ~/DynamicData/CustomPage/TableName/Page.aspx this is the default behavoir. DD routes always translate to the ~/DynamicData folder if there is a CustomePages folder for that table it will look there fist for the relavent page if not it will use a page from the PageTemplates folder.
OK so far.
Now if you have add a new route into the equasion it's still going to look at thing in the above way unless you make it clear in your route that the file is outside the ~/DynamicData folder.
See my example of running two models Dynamic Data – Registering Multiple Models and David Ebbo's Using Dynamic Data with multiple databases these may be of some help.
So if I had a page ~/Articles.aspx (in the root) of the site I would not need to provide a route to acces this file unless I wanted to have the paramter slug passed in as part of the url:
~/Articles.aspx?slug=10
So if I wanted to have a url like:
~/Articles.aspx/10
or
~/Articles/10
the I could add my own route handler, because if you look at a route:
routes.Add(new DynamicDataRoute("{table}/{action}.aspx") { Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }), Model = model });As you can see the route is a DynamicDataRoute.
For details non DD route see Mike Ormond's Getting ASP.NET Routing Up and Running - The Definitive Guide
Dynamic Data routing
Always seeking an elegant solution.