I am using the MVC Attribute Routing (MVC 5.1.2) and am running into the error:
Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL.
The request has found the following matching controller types: FFInfo.WebUI.Areas.Admin.Controllers.HomeController FFInfo.WebUI.Areas.Admin.Controllers.SectionController
This only happens when I go to /Admin/Sections/
and I am not really sure why since there is only one route that can match that URL, can anyone help me figure out what is wrong? Please note this problem is unique to 5.1.2, MVC 5.0 it works fine.
Base Controller:
[RouteArea("Admin")]
public class BaseController : Controller
{
}
Home Controller:
[RoutePrefix("")]
[Route("{action}")]
public class HomeController : BaseController
{
public ActionResult Index()
{
}
public ActionResult Updates()
{
}
[ChildActionOnly]
public PartialViewResult GetUpdatesGrid()
{
}
public ActionResult GetUpdates(JqGridRequest Request)
{
}
}
Section Controller:
[RoutePrefix("Sections")]
[Route("{action}")]
public class SectionController : BaseController
{
[Route]
public ActionResult Sections()
{
}
[ChildActionOnly]
public PartialViewResult GetSectionsGrid()
{
}
public ActionResult GetSections(JqGridRequest Request)
{
}
public ActionResult AddSection()
{
}
[HttpPost, ValidateAntiForgeryToken]
public ActionResult AddSection(AddEditSectionVM model, HttpPostedFileBase LogoFile)
{
}
public ActionResult EditSection(Int16? ID)
{
}
[HttpPost, ValidateAntiForgeryToken]
public ActionResult EditSection(AddEditSectionVM model, HttpPostedFileBase Logo)
{
}
public ActionResult Releases()
{
}
[ChildActionOnly]
public PartialViewResult GetReleasesGrid()
{
}
public ActionResult GetReleases(JqGridRequest Request)
{
}
public ActionResult AddRelease()
{
}
[HttpPost, ValidateAntiForgeryToken]
public ActionResult AddRelease(AddEditReleaseVM model)
{
}
}
My understanding of the RouteArea
RoutePrefix
, and Route
attributes tells me that /Admin/Index
will call the Index
ActionResult
of the Home Controller and the URL Admin/Sections
should call the Index
ActionResult
of the Sections Controller. All the other routes work perfectly fine in each controller and when you go to /Admin/Index
that works fine. I only get this error when I go to /Admin/Sections
. What is wrong?