Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
multiple page routing not working in asp.net

i have a multiple asp.net web form i am trying to route of all but first page can route work rest of theme all are not working

What I have tried:

by code
Globle.asax

void Application_Start(object sender, EventArgs e)
{
RegisterProductRoutes(RouteTable.Routes);
}

public static void RegisterProductRoutes(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("RouteForCatagory", "bath-accessories-{CategoryName}", "~/ProductInner.aspx");

routeCollection.MapPageRoute("RouteForProduct", "kp/{Product}-{CategoryName}", "~/ProductDetails.aspx");

}

First.aspx

<a  href='<%# GetRouteUrl("RouteForCatagory", new {CategoryName = ReplaceSpace(Eval("CategoryName")).Trim()})%>'><%# Eval("CategoryName").ToString().Trim() %></a>



Second.aspx

<a href='<%# GetRouteUrl("RouteForProduct", new {ProductName = ReplaceSpace(Eval("ProductName")).Trim(),CategoryName = ReplaceSpace(Eval("CategoryName")).Trim()})%>'><%# Eval("ProductName").ToString().Trim() %></a>
Posted
Updated 11-Jun-20 9:19am
v2
Comments
kalpeshnariya 12-Jun-20 6:09am    
routeCollection.MapPageRoute("DefaultRoute", "{Name}", "~/Default.aspx");

and

a href='<%# GetRouteUrl("DefaultRoute", new {Name = "Index"})%>'>Home

1 solution

Quote:
C#
routeCollection.MapPageRoute("RouteForProduct", "kp/{Product}-{CategoryName}", "~/ProductDetails.aspx");
...
GetRouteUrl("RouteForProduct", new {ProductName = 
Surely the token names need to match? Either the token in the route should be ProductName, or the property name in the route values should be Product.
 
Share this answer
 
Comments
kalpeshnariya 11-Jun-20 23:41pm    
ohhhhhh i have a mistake..
thank you very much Richard Deeming
kalpeshnariya 12-Jun-20 6:35am    
routeCollection.MapPageRoute("DefaultRoute", "{Name}", "~/Default.aspx");
and
a href='<%# GetRouteUrl("DefaultRoute", new {Name = "Index"})%>'>Home
this also not working.. where is my mistake in this code. please help me.
Richard Deeming 12-Jun-20 11:58am    
That route is going to catch a lot of requests. It's probably conflicting with another route you have defined.
kalpeshnariya 13-Jun-20 0:27am    
so what can i do please tell me and please give me suggestion
Richard Deeming 15-Jun-20 5:07am    
Check your other routes. Try using the route debugger package:
Debugging ASP.NET Web API with Route Debugger | ASP.NET Blog[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900