我试图将带参数和不带参数的url路由到两种不同的方法,但是由于某种原因,它总是从第一个开始。
这是控制器代码:
public class ProductController : Controller
{
[Route("")]
[Route("Product")] //If i delete this one then it works how it is intended
public IActionResult Index()
{
//It always start this one
....
}
[Route("Product/{GroupID?}")]
public IActionResult Index(int GroupID)
{
....
}
}