-
Notifications
You must be signed in to change notification settings - Fork 0
MVC Examples
Stephan van Leeuwen edited this page Apr 23, 2021
·
9 revisions
This page shows how you can use UrlActionGenerator and what methods are generated in what scenario.
Controller:
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
Usage:
Url.Actions().Home.Index() // => "/Home/Index"
Controller:
public class HomeController : Controller
{
public IActionResult Search(int page, int pageSize = 20)
{
return View();
}
}
Usage:
Url.Actions().Home.Search(1); // => "/Home/Search?page=1"
Url.Actions().Home.Search(2, 50); // => "/Home/Search?page=2&pageSize=50"
Controller:
[Area("Admin")]
public class HomeController : Controller
{
public IActionResult Index(string str)
{
return View();
}
}
Usage:
Url.AdminActions().Home.Index("value"); // => "/Admin/Home/Index?str=value"