09-URL生成

通过URL类可以生成URL连接。

[Route("")]
[Route("home")]
[Route("home/index")]
public IActionResult Index()
{
    return Content(Url.Action("abc"));
}Code language: PHP (php)

注意 如果action不存在则会返回null的

[Route("")]
[Route("home")]
[Route("home/index")]
public IActionResult Index()
{
    //return Content(Url.Action("Index"));
    //return Content(Url.Action("Index", "Home"));
    //return Content(Url.Action("Index", "Course", new { id=1,name="xiaopan" }));
    return Content(Url.RouteUrl("blog"));
}Code language: PHP (php)

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注