I create a number of actions in MVC controllers.
public ActionResult DoSmth1(string token) public ActionResult DoAnother2(string token)
And when I need to call ActionLink ..
=Html.ActionLink<SomeController>( x=> x.DoSmth(item.property), item.property) =Html.ActionLink<AnotherController>( x=> x.DoAnother(item.property), item.property)
... it generates me different urls:
/Some/DoSmth/stringvalue /Another/DoAnother?property=stringvalue
Where to set the way to create the url? I have no ideas ... ((
Well, a got some light: - if the property names are the same as those used in the routing scheme - for example, the controller, action and identifier - MVC will always use the route builder (/ c / a / id).
This helps a bit (so - name the parameter "id" as much as possible ))
But the general problem remains valid ...
should be named just like the token in the route
Exactly - I had my first idea.
But now I only have the default route ({controller} / {action} / {id}), but still have a URL with a "property" in outline ... This is pretty weird.
- there is also a fraudster - to create an exact route that matches the given controller with its parameter names - it seems that this will be the final answer - but I still do not want to do this ((
Sketch
source share