Reputation: 1625
i have a set of routes defined in System.Web.Routing and in need to get the actual url's with the .aspx extension. i've tried this code but i'm doing something wrong here:
var path = RouteTable.Routes.GetVirtualPath(null, item.Link, null);
var link = path.Route.GetVirtualPath(null, null);
if (link.VirtualPath.ToLower().Contains("~/displaycmspage.aspx?pagename="))
{
//do work on url here
}
any idea on how i can do this? The item.link is a custom object where i have the route.
Upvotes: 1
Views: 617
Reputation: 1625
ok, so i found the answer :
var path = RouteTable.Routes[item.Link];
Route ruta = path as Route;
var link = ruta.RouteHandler as PageRouteHandler;
if (link.VirtualPath.ToString().ToLower().Contains("~/displaycmspage.aspx?pagename="))
{
//do work on url here
}
Upvotes: 1