views:

31

answers:

1

Hi all,

I'm experimenting with asp.net routing (using webforms). I got it to work fine and I retrieve an url like this:

    public static string FormatReviewUrl(string title)
    {
        return RouteTable.Routes.GetVirtualPath(null, "Review", new RouteValueDictionary { { "Item", title } }).VirtualPath;
    }

Problem however is my url structure looks like this http://domain/electronics/samsung-led-tv

So I also want to include 'electronics'. But I have no idea how to use the above function to return an url with multiple items. I got it to work just using 'item' but if i include 'category' in the dictionary I have no way to retrieve the virtual path. I was thinking something like this but i failed bigtime:

   public static string FormatReviewUrl(string title)
{
    return RouteTable.Routes.GetVirtualPath(null, "Review", new RouteValueDictionary { { "Item", title, "Category", categorytitle } }).VirtualPath;
}

I hope that you know what I'm trying to achive here, thanks for your time!

A: 

Ok figured it out, should have created the routevaluedir and add items to it. Thought it didn't work before but it did!

RouteValueDictionary rvd = new RouteValueDictionary();
Mark