开发者

Action parameters showing up in querystring instead of URL

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜