title: How to create friendly url in asp.net webform with single route
body: <p>I am not sure if it is possible to create complete friendly url (Slug i think they call it in wordpress).</p>
  
  <p>I want to create friendly url dynamically with single route defined in global.asax file.</p>
  
  <p>example :</p>
  
  <pre><code>about-us/
  
  about-us/who-we-are/
  
  about-us/sub-page/sub-page2/
  
  media/news/
  
  media/photo-gallery/
  
  media/press/
  </code></pre>
  
  <p>at present i have to define route for each url mentioned about.</p>
  
  <p>I have tried in past to create above route with single route defined in gloabal.asax</p>
  
  <p>example</p>
  
  <p>in global.asax file i make call to database table and get information like Page_Name, Page_Handler, Page_Title ...</p>
  
  <pre><code>//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" }
                      });
  </code></pre>
  
  <p>How can i create this route dynamically so that i can pass <code>about-us/</code> &amp; 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.</p>
  
  <p>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.</p>
  
  <p>In wordpress they create pages &amp; friendly page name can we achieve same in asp.net web forms.</p>
  
  <p>sample table with data</p>
  
  <pre><code>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/   
  </code></pre>