I am not sure if it is possible to create complete friendly url (Slug i think they call it in wordpress).
I want to create friendly url dynamically with single route defined in global.asax file.
example :
about-us/
about-us/who-we-are/
about-us/sub-page/sub-page2/
media/news/
media/photo-gallery/
media/press/
at present i have to define route for each url mentioned about.
I have tried in past to create above route with single route defined in gloabal.asax
example
in global.asax file i make call to database table and get information like Page_Name, Page_Handler, Page_Title ...
//Create Route
//some logic to get url segments so that it can be passed to
getPageDetails(PageURL)
{
//logic to get PageHandler so that route can be created
}
//For general.aspx Page
routes.MapPageRoute("Page", "about-us/", "~/Aboutus.aspx", false,
new RouteValueDictionary {
{ "path", "Page-not-found" },{ "PageName", "Page-not-found" }
});
How can i create this route dynamically so that i can pass about-us/ & pageHandler dynamically so that one route function call route for all page. If this is possible then i can add as many page to website with making change to global.asax route section by addition additional routes.
Please advice how to call database function to get pagehandler and assign it to route to handle the routing i am not sure if this is possible.
In wordpress they create pages & friendly page name can we achieve same in asp.net web forms.
sample table with data
Page_ID Page_Name Page_Handler Page_URL
1 About Us General.aspx /about-us/
2 Who we are General.aspx /about-us/who-we-are/
3 ... .. /about-us/sub-page/sub-page2/
4. Media #
5 News news.aspx /media/news/
6 Photo Gallery galler.aspx /media/photo-gallery/