我在MVC控制器中创建了一些操作。
public ActionResult DoSmth1(string token)
public ActionResult DoAnother2(string token)
当我需要调用ActionLink时..
=Html.ActionLink<SomeController>( x=> x.DoSmth(item.property), item.property)
=Html.ActionLink<AnotherController>( x=> x.DoAnother(item.property), item.property)
它会生成不同的URL:
/Some/DoSmth/stringvalue
/Another/DoAnother?property=stringvalue
在哪里设置构建URL的方式?我已经没有任何想法...((
OK, a got some waylight: - if the property names are the same that used in routing schema - eg controller,action and id - the MVC will always use the route builder (/c/a/id).
那有一点帮助(因此-尽可能命名参数“id”)
但是总体问题仍然存在...
必须与路由中的令牌名称相同
确切地说-我最初就有那个想法。
但是-现在我只有默认路由({controller}/{action}/{id}),但仍然在斜杠中有“property” URL... 这相当奇怪。
- there s also a cheater way - to create a precise route that match a given controller with it s parameter names - is seems that will be the ultimate answer - but i still don t want to do this ((