I am going to implement routing feature in my asp.net4.0 application and following the given link:
This is fine if an application has limited no. of pages but my application has lots of pages.
so i have to write code [ routes.MapPageRoute(“”,””,””); ] many times.
Can we map all pages by looping through any collection classes or by any other method.
Thanks
If you have a standard pattern for your url and your file structure you can use the placeholders in the mapped url too
eg. If you can map every “{controller}/{action}/{id}” to “/Pages/{controler}/{action}.aspx”
For example, i build a site that has this folder structure
Under the root folder there is the Views folder where all my pages reside.
Under the Views folder there is one subfolder for every “controller” (there is no controllers in webforms, but I follow the MVC conventions here)
Under the controllers subfolders there are the aspx pages that represent different actions
The aspx page names are the same for each controller (“Index.aspx”,”Add.aspx”,”Edit.aspx” etc)
So I can have a general mapping rule
I don’t need different rules for different pages as long as the folder structure follows this pattern
Now
etc, all matching this one rule above.
of course if you want to override this rule you can define more specific routes BEFORE defining this one.