【发布时间】:2023-02-03 11:17:57
【问题描述】:
这两个动作路由在 .netcore 2.1 中工作正常,但在迁移到 .netcore 6 后显示错误:AmbiguousMatchException: The request matched multiple endpoints
我关注了https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-6.0 但无法解决问题。
//Just for two route /content/game & /content/software
[Route("/content/{pageId=game}")]
[Route("/content/{pageId=software}")]
public IActionResult Index1(string pageId, [FromQuery] int page=1)
{}
//For all other url(/content/*)
[Route("/content/{package}")]
public IActionResult Index2(string package)
{}
【问题讨论】:
-
第二个有两条相同的路线?
-
Ralf 上面的评论,还有你的第一个动作路线以“/”开头,而第二个不是,是故意的吗?
-
您实际上期望发生什么?我会让你的游戏/软件路线用他们的页面名称明确
-
这是错字。更新问题。仍然显示错误。
-
我想将
/content/game和/content/software路由到Index1和/content/anythingElse到Index2
标签: c# asp.net-core