I am working with URL rewriting, and have some issues. I want my url to be like this:
www.domain.com/product/myproduct
But I also want to be able to retrieve the ID of the product, without accessing the database. I thought about having a URL like:
www.domain.com/product/myproduct/1
or
www.domain.com/product/1-myproduct
But if I could hide the ID it would be better.
So, how do I do it the simplest way?
Currently my Global.asax has the following route:
routes.MapPageRoute("Produkt visning",
"legetoej/{Categoryname}/{SubCategoryname}/{ProductName}",
"~/SingleProduct.aspx");
And when I retrieve the name I do like this on SIngleProduct.aspx:
object productRoute = Page.RouteData.Values["ProductName"];
if (productRoute != null && !string.IsNullOrEmpty(productRoute.ToString()))
{
// do stuff
}
If I very simple could just get the ID instead of name, it would be awesome.
Thanks a lot awesome-stackoveflowers ;-)