ASP.NET MVC隐式添加路由值路由、隐式、ASP、NET

2023-09-07 09:32:33 作者:荒废度过~青春

我创建的ActionLink调用Html.ActionLink并传递路线反对。不过貌似ASP.NET MVC隐式地从当前通话增加等航线。

I create ActionLink calling Html.ActionLink and passing route object to it. But looks like ASP.NET MVC implicitly adds other routes from current call.

例如,如果我有两条路线:SomePage的/页/ {PAGE}和SomePage的,目前用户所请求的页面与第一根,网页路线值将被默认添加到ActionLink的可以和我'T创建ActionLink的第二个根源。

For example, if I have two routes: "somepage/page/{page}" and "somepage" and currently user requested the page with the first root, "page" route value will be implicitly added to ActionLink and I can't create ActionLink to the second root.

推荐答案

你是如何为了您的路由定义?的顺序是非常重要的!最具体的路线应该是第一条路线,你必须定义和最常见的是最后一个。

How did you order your route definitions? The order is very important! The most specific route should be the first route you have to define and the most common the last one.