issue with assigning MVC controller/actions for inherited classes

Nov 10, 2008 at 5:12 PM
Hi there

I've just run into an issue with MVC in N2: I've got 2 page classes that are involved in the issue (class implementations omitted for brevity)


[Definition("About Us Child Page")]
    [RestrictParents(typeof(AboutUsRootPage))]
    public class AboutUsSectionPage : GenericPage
    {
       
    }

[Definition("Executive Team Page")]
    [RestrictParents(typeof(AboutUsRootPage))]
    public class ExecutiveTeamPage : AboutUsSectionPage
    {
        
    }

I have 2 seperate controllers:

[Controls(typeof(AboutUsSectionPage))]
    public class AboutUsSectionPageController : ContentItemControllerBase<AboutUsSectionPage>
    {
        public override ActionResult Index()
        {
            //returns a specific view
        }
    }

[Controls(typeof(ExecutiveTeamPage))]
    public class ExecutiveTeamController: ContentItemControllerBase<ExecutiveTeamPage>
    {
        public override ActionResult Index()
        {
            //returns a specific view
        }
    }

Now the problem that I am encountering is that when I try to view a page in the page tree that is of type ExecutiveTeamPage that exists as a child of a page of type AboutUsSectionPage, the AboutUsSectionPageController  is instantiated and execution is routed to the Index() method.

I need to do one of the following:

  1. Get routed to the Index() method on ExecutiveTeamController, or
  2. Get routed to another method within AboutUsSectionPageController
Has anyone run into this issue before? I'm assuming that I need to specify custom routes somehow.

Graham
Coordinator
Nov 10, 2008 at 7:30 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.