[NOTE: I am using ASP.NET MVC2 RC2.]
I have URLs like this:
/ customers / 123 / orders / 456 / points / index
/ customers / 123 / orders / 456 / items / 789 / change
My routing table lists the most specific routes, so I got:
routes.MapRoute(
"item",
"customers/{customerId}/orders/{orderId}/items/{itemId}/{action}",
new { controller = "Items", action = "Details" },
new { customerId = @"\d+", orderId = @"\d+", itemId = @"\d+" }
);
routes.MapRoute(
"items",
"customers/{customerId}/orders/{orderId}/items/{action}",
new { controller = "Items", action = "Index" },
new { customerId = @"\d+", orderId = @"\d+" }
);
When I am on the Edit page, I need a link to the Index page. So, I use:
ActionLink("Back to Index", "index")
However, since there is an object-object identifier, this leads to the URL:
/ customers / 123 / orders / 456 / points / 789 / index
... whereas I want it to "forget" the identifier of the element and simply use:
/ customers / 123 / orders / 456 / points / index
I tried to override the item id as follows:
ActionLink("Back to Index", "index", new { itemId=string.empty })
... . :
//123//456/? Itemid = 789
ActionLink "" ?
EDIT: - "", "".
EDIT: ββ , itemId = string.empty .