webforms routing: optional parameters


I want to add optional parameters in my routing table.
For example I would like the users to browse a product catalog like this:,2,3 etc

Now i've created a route like this:


Problem however is that when a user enters , I would like them to present a different page where they can pick the manner on how to browse. So the parameters {BrowseBy} and {Category} will not be used.

Is there a way around this then to create seperate routes for each of the scenarios?

Thank you for your time!
Kind regards,

Best Solution

I just came across this question, and knew there had to be way to do this. There is-

MapPageRoute has an overload that will allow you to specify defaults. here's an example usage based on your code:

        new RouteValueDictionary { { "Category", string.Empty } }

So if the user doesn't specify a category this route will still be hit. The problem I have with using two separate routes is that I have links setup around my site that are generated by route name, and you cannot have two routes that have the same name.

Here's good documentation from MSDN: here

Related Question