.net core3.1路由配置伪链接该怎么配置

2020-09-23 17:07发布

endpoints.MapControllerRoute(
name: "blog-list",
pattern: "{controller}/{category?}",
defaults: new { Controller = "Blog", Action = "List" }
);
endpoints.MapControllerRoute(
name: "blog-info",
pattern: "{controller}/{action}/{id?}"
);

比如说我想配置 /blog/58.html

其中58是id

1条回答
forever°为你锁心
2楼-- · 2020-09-23 17:24

假如 Action 名称是 Info ,可以使用下面的路由配置

endpoints.MapControllerRoute(
    name: "blog-info",
    pattern: "{controller}/{id}.html",
    defaults: new { Controller = "Blog", Action = "Info" }
);
查看更多
登录 后发表回答