有沒有辦法為剃須刀頁面指定自定義路由名稱?
對于控制器和動作,例如,可以使用RouteAttribute如下方式:
[Route("my-custom")]
public class MyCustomController
{
[Route("my-index")]
public IActionResult MyIndex() => View();
}
是否有關于剃須刀頁面的類似方法?
uj5u.com熱心網友回復:
可以通過@page在 cshtml 檔案中自定義指令的路由模板來實作。
例如,在MyIndexPage.cshtml剃須刀頁面中;
@page '/my-index'
@model MyIndexPageModel
...
/不要忘記開頭的正斜杠 ( )。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/518148.html
標籤:C#asp.net 核心asp.net-core-mvc剃刀页面
上一篇:如何將依賴項注入物體模型?
下一篇:301重定向不適用于索引檔案
