I am developing a CMS that stores user content in a database table like this:
---------------------------------------- PageId | PageTitle(Unique) | Content ---------------------------------------- 1 | PageOne | ... 2 | PageTwo | ... 3 | PageThree | ... 4 | PageFour | ...
Now I have an aspx page “SitePageFactory.aspx” at root that serves dynamic content when a querystring is passed to it, suppose /SitePageFactory.aspx?pgid=1 is passed then it serves the content for PageOne.
The concept above is working fine.
Now I want to put a step further by adding dynamic routes to this application and modify /SitePageFactory.aspx?pgid=1 to /PageOne.aspx but unable to do it at root level.
NOTE: Currently I am able to perform routing like /SitePageFactory/PageOne.aspx but I want the results at the root level.
Thanks.
You can use ASP.NET Routing to accomplish this.
Routing let’s you map an url like: http://www.mysite.com/pages/pageone to an aspx page. The different parts in your url can be mapped to route parameters that you can access in your aspx.
Here is the MSDN documentation for routing.
You can add the folowing route:
This will map the url http://www.yourdomain/ to the Page controllers ViewPage method.