我有两个控制器设置:
[Route("/My/Path/{id}/Parent")]
public class ControllerParent ... { ... }
[Route("/My/Path/{id}/Parent/{parentId}/Child")]
public class ControllerChild ... { ... }
...在运行时,此 URL 以某种方式转到
ControllerParent
,而不是预期的 ControllerChild
:
https://webhost/My/Path/{id}/Parent/{parentId}/Child/Delete/{key}
而这个进入正确的控制器,并且断点命中
ControllerChild
,正如预期的那样:
https://webhost/My/Path/{id}/Parent/{parentId}/Child/{key}
您是否尝试将
action
参数添加到如下所示的路线中?
[Route("/My/Path/{id}/Parent/{action}/{key?}")]
public class ControllerParent : Controller { ... }
和
[Route("/My/Path/{id}/Parent/{parentId}/Child/{action}/{key?}")]
public class ControllerChild : Controller { ... }