HEXAQ : A friendly question - answer site for IT professionals

Webpage routing is not working properly with same type of page route urls


0

I am using RoutesCollection class, details listed on MSDN for routing webpages.

My routes.MapPageRoute method contains same number of parameters as below

routes.MapPageRoute("customers", "customer", "~/customer.aspx"); 

routes.MapPageRoute("products", "product", "~/product.aspx");

When I navigate http://www.website.com/product it always goes to customer page.

Is there any way to manage similar type of routes in ASP.NET?

Â
asked
 


≡ Total 1 Answer

0

one solution to this is to check for RouteValueDictionary of route value for example if "customer" in routes.MapPageRoute("customers", "customer", "~/customer.aspx"); is cusomer name then you can use

routes.MapPageRoute("customers", "customer", "~/customer.aspx",false , null, new RouteValueDictionary { { "customer", "[a-z][A-Z]*" });); 

and for product in routes.MapPageRoute("products", "product", "~/product.aspx"); is a integer value you can use

routes.MapPageRoute("customers", "customer", "~/customer.aspx",false , null, new RouteValueDictionary { { "customer", "[0-9]*" });); 

In short you have to found validations for your route values

Â
replied


Enter your reply here
Answer Preview:
Viewed: 1036 times
Asked on: 5/29/2013
Permalink
Topics in this question
  50
  2
Search Question
Similler Questions