我正在使用MVC 5.1和AutoFac。MVC路由衝突似乎很奇怪
我不明白爲什麼從這個URL每個控制器衝突以下路線:https://localhost:44300/Home/login
我認爲這將映射到第一個方法。我得到這個錯誤:
發現多個控制器類型與URL匹配。如果多個控制器上的屬性路由匹配請求的URL,就會發生這種情況
請求發現下列匹配控制器類型: AllThings.WebUI.Controllers.AccountController AllThings.WebUI.Controllers.PostController
public class AccountController : Controller
{
//
// GET: /Account/Login
[Route("~/{site}/Login")]
[Route("~/Account/Login")]
[Route("~/{country:maxlength(2)}/{site}/Login")]
[Route("~/{country:maxlength(2)}/Account/Login")]
[AllowAnonymous]
public ActionResult Login(string returnUrl, string country, string site)
{
return View();
}
}
public class PostController : Controller
{
[Route("~/{site}/{CategoryUrl?}")]
[Route("~/{country:maxlength(2)}/{site}/{CategoryUrl?}", Name = "ResultList")]
[AllowAnonymous]
public ActionResult List(string country, string site, SearchCriteriaViewModel searchCriteriaViewModel)
{
return View("List", searchCriteriaViewModel);
}
}