Search code examples
asp.net-mvccontent-management-systemasp.net-mvc-3n2n2cms

N2 CMS and MVC 3 RC causes "The current request for action 'Index' on controller...is ambiguous...'


I've used N2 CMS for a while now, I've just updated to use MVC 3 RC and I'm now recieving this error on every page:

The current request for action 'index' on controller type 'HomeController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Index() on type Project.Web.Controllers.N2Controller1[[Project.Web.Models.HomePage, Project.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] System.Web.Mvc.ActionResult Index() on type N2.Web.Mvc.ContentController1[[Project.Web.Models.HomePage, Project.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

Just to explain I have a HomeController, that inherits from N2Controller< HomePage >, N2Controller< T > inherits from N2.Web.Mvc.ContentController< T >.

Each controller, Home, Account etc don't have Index methods because the ContentController already has one.

This all worked absolutely fine with MVC 2, but with MVC 3 RC it's throwing this error.

Any ideas anyone? I can't find anything online...

Cheers, Ash.


Solution

  • This sounds like N2Controller has an Index method which should be set to override the Index method in ContentController.

    The way an action method is resolved on a controller must have changed between MVC2 and 3 to take into account the inheritance hierarchy, causing this problem.