ASP.NET 4.0 webforms routing

Posted by Ethan on Stack Overflow See other posts from Stack Overflow or by Ethan
Published on 2010-05-09T19:08:24Z Indexed on 2010/05/09 19:18 UTC
Read the original article Hit count: 261

Filed under:
|
|
|

I have an existing site that I'd like to convert to use routing, and after reading Scott Guthrie's post here, I built a working sample that works for most circumstances. However, since not all of the pages on the existing site match a particular pattern, I'll need to check against a database to determine which route (destination .aspx page) to use.

For example, most pages are like this:

http://www.mysite.com/people/person.html

This is fine - I can easily route these to the view_person.aspx page because of the 'people' directory.

But some pages are like this:

http://www.mysite.com/category_page.html http://www.mysite.com/product_page.html

This necessitates checking the database to see whether to route to the view_category.aspx page or the view_product.aspx page. And this is where I'm stuck. Do I create an IRouteHandler that checks the database and returns the route? Or is there a better way? The only code I've found that kind of fits is the answer to this question.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about 4.0