ivaylokenov / AspNet.Mvc.TypedRouting

A collection of extension methods providing strongly typed routing and link generation for ASP.NET Core MVC projects.
https://mytestedasp.net/
MIT License
485 stars 36 forks source link

Get Action name without passing parameters #24

Closed v-zmiycharov closed 7 years ago

v-zmiycharov commented 7 years ago

Let's say I have a method with one required parameter

[HttpPost]
IActionResult Test(int id).

If I want it to be post parameter I can't use the Url.Action<HomeController>(c => c.Test()) because I have to pass "id".

ivaylokenov commented 7 years ago

@v-zmiycharov The C# compiler does not allow such call. This is why there is a special With class. You can use it like this to specify no action arguments in the route values:

Url.Action<HomeController>(c => c.Test(With.No<int>()))