One way to achieve this is to create custom RouteConstraint by inheriting IRouteConstraint and store your urls in xml. You will need to know the page template type so you could store this information in an enum like this:
public enum TemplateType
{
Home,
Product,
Category
}
Here is an example xml that you can use to store your data:
<Sitemap>
<Item url="/home" TemplateType="Home" />
<Item url="/products/category" TemplateType="Category">
<Item url="/products/category/product" TemplateType="Product" />
</Item>
</Sitemap>
After that you will need method to extract Sitemap nodes and get specific node. You simply need to deserialize the xml and traverse it to find specific url.
Your custom RouteConstraing should be something like this:
public class CustomRouteConstraint : IRouteConstraint
{
#region IRouteConstraint Members
private TemplateType m_type;
public CustomRouteConstraint(TemplateType type)
:base()
{
m_type = type;
}
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
bool returnValue = false;
SitemapNode sitemapNode = GetSiteMapNode(httpContext.Request);
if (sitemapNode != null && sitemapNode.TemplateType == m_type)
{
return true;
}
return returnValue;
}
#endregion
private static SitemapNode GetSiteMapNode(HttpRequestBase request)
{
//get the aboslute url
string url = request.Url.AbsolutePath;
return SitemapManager.GetSiteMapNode(url);
}
}
After you have all of this in place in your Global.asax file in the RegisterRoutes method you need to do something like this:
routes.MapRoute(
"", // Route name
route, // URL with parameters
new { lang = "en", region = "us", controller = "Category", action = "Index" },
new { param1 = new CustomRouteConstraint(TemplateType.Category) });
Hope this helps.