Making id'less url in asp.net mvc razor
Posted
by
Sushant
on Stack Overflow
See other posts from Stack Overflow
or by Sushant
Published on 2012-10-25T10:57:40Z
Indexed on
2012/10/25
11:00 UTC
Read the original article
Hit count: 270
I am working with URL routing , and have some issues. I want my url to be like this:
www.domain.com/p/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/p/myproduct/1
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.MapLocalizedRoute("Product",
"p/{productId}/{SeName}",
new { controller = "Catalog", action = "Product", SeName = UrlParameter.Optional },
new { productId = @"\d+" },
new[] { "Nop.Web.Controllers" });
© Stack Overflow or respective owner