【发布时间】:2020-01-23 17:17:30
【问题描述】:
我的控制器中定义了 2 条路由:
[HttpGet]
[Route("{customerId}")]
public IActionResult GetCustomerOrders(string customerId)
{
}
[HttpGet]
[Route("{customerId}/{orderId}")]
public IActionResult GetCustomerOrder(string customerId, string orderId)
{
}
现在,如果有人传入像 http://myApp/api/Orders//6d1a30ed-045b-4ea3-845e-e1b7ebd8f6a5 这样的 url(所以 customerId 为空);它最终匹配第一条路线(customerId 参数中的orderId);但我真的希望它去第二。我怎样才能使它在customerId 中以空值落在第二位?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-routing