URL Routing with WebForms, what to do with additional querystrings like page number, filter, etc?

Posted by Scott on Stack Overflow See other posts from Stack Overflow or by Scott
Published on 2010-04-20T17:11:51Z Indexed on 2010/04/20 17:13 UTC
Read the original article Hit count: 433

Filed under:
|
|
|

I am switching from Intelligencia's UrlRewriter to the new web forms routing in ASP.NET 4.0. I have it working great for basic pages, however, in my e-commerce site, when browsing category pages, I previously used querystrings that were built into my pager control to control paging.

An old url (with UrlRewriting) would be:

http://www.mysite.com/Category/Arts-and-Crafts_17

I have a MapPageRoute defined in global.asax as:

routes.MapPageRoute("category-browse", "Category/{name}_{id}", ~/CategoryPage.aspx");

This works great. Now, somebody clicks to go to page 2. Previously I would have just tacked on ?page=2 as the querystring. Now, How do I handle this using web forms routing? I know I can do something like:

http://www.mysite.com/Category/Arts-and-Crafts_17/page/2

But in addition to page, I can have filters, age ranges, gender, etc. Should I just keep defining routes that handle these variables, or should I continue using querystrings and can I define a route that allows me to use my querstrings like before?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about 4.0