I'm doing this:
@Url.Action("De开发者_如何转开发tails", "MyController", new { id = this.Model.ID })
The URLcomes out like this: /MyController/Details?id=1
How do I get it to format the URL like this: /MyController/Details/1
The routes look like this:
routes.MapRoute("Default", "{Controller}/{Action}", new { Controller = "Home", Action = "Index" });
routes.MapRoute("Default-ID", "{Controller}/{Action}/{ID}");
The order of routes matters - both urls are valid, and in this case the system gets to the query string one first when looking for a url matching that action.
There's also a possibility you have a case sensitivity issue with {ID} - not sure about that one, but generally it is best to use case consistently.
精彩评论