I use @Html.Action(..,..) on the _Layout.cshtml to render an action sensitive menu (it's model depends on he action and its parameters). It worked before I added the Mef2 references.
I added the Mef2 references, made the Parts folder and the classes in a right named namespace. Added the constructor to my Controller class. The child action is in the CatalogController and this controller needs a resolved part.
Now it works nice with any actions of any Controller but the CatalogController. If I use an url that tarets the same controller (for this case: localhost:3456/Catalog/Index) what the Html.Action then I get the error:
A single instance of controller 'Shop.Web.Controllers.CatalogController' cannot be used to handle multiple requests. If a custom controller factory is in use, make sure that it creates a new instance of the controller for each
and it happens on the Html.Action line
Line 25: </header>
Line 26: <nav id="sidemenu">
Line 27: @Html.Action("Menu","Catalog")
Line 28: </nav>
Line 29: <section id="main">
So it seems I can not use child actions in the same controller where the actual main action resides.
Is it by design or I missed something? Can I make it work somehow?