ASP.NET MVC - Routing Engine Appending Unexpected Values -
I have a route that points to both taking the same action and based on the route data supplied I like the way one can be selected on the other The problem is that the routing engine automatically adds the root values that I'm not explicitly telling this.
route. New {pageNbr = @ "\ d +"}, new [] {"Web", "New", "MapRoute" ("Products_Search_Paged", "products / search / page {pageNBR}", new {controller = "product", verb = "search" .components.Controllers "}); Routes.MapRoute ("Products_Search", "Product / Search", New {Admin = "Product", Action = "Search"}, New [] {"Web.Components.Controllers"});
Note that the only difference between the two routes is in addition to Products_Search_Paged in / page {pageNbr} .
The problem I am facing is that when I / products / search / page2? For example, if I see Url.Action ("search," product ", new {pageNbr =" "}}, then I'm looking for the Products_Search_Paged route on the name = foo
, I want to create a link for / products / search is ignoring my announcement pageNbr = ""
and Url.Action () "search", "product", the new {pageNbr => / products / search ... pageNbr = 2 5}) I end up with / products / search / page5 , as expected
I tried to reconstruct the routes and put Products_Search_Paged before the product search , which, even after ending it, PageNbr = # It is being added even after being removed, but its effect has no formatting
By trial I have done so far, I can not do it for any reason that it shows that the value of the path pageNbr should be added as its current value Being, whenever I have set some more explicitly in the rootwallis given to him.
Two solutions to this problem are clearly defined to use either Url.RouteLink ()
on the path that I want to use. , Or manually by generating the pageNbr key URL from the root data. However, before choosing one of those solutions, I was hoping someone might be able to recognize me that my present, it seems that the proper approach is not producing results.
Flip announcements, add a default value for page URL of a NBR, and then 1 Call the page of NBT. The advantage of this is that the link to pagenbr of 1 would be a simple link.
Comments
Post a Comment