Try our conversational search powered by Generative AI!

ControllerTypeControllerFactory / MvcContentRenderer / non-CMS controller

Vote:
 

I've standard MVC controller, that has an action which returns partial view.

I wan't to be able to use it inside cms-content template (MVC view with corresponding controller MyCmsContentController):

@{ Html.RenderAction("MyRegularAction", "MyRegularMvcController"); }

    

Let's say in put my cms-content inside ContentArea or render content directly using:

 @{ Html.RenderContentData(cmsContent, false, "tag");}

    

As a result I will have following error:

A public action method 'MyRegularAction' was not found on controller 'MyCmsContentController'.

 

Suppose that is a bug.

1. MvcContentRenderer put controllerType key into route values dictionary (occurs when you render content area content)

2. controllerType is used by ControllerTypeControllerFactory to get controller instance; my MyCmsContentController instance is returned

3. now I try to get output from my regular mvc controller (call made by html helper inside cms content template), but ControllerTypeControllerFactory always returns wrong controller instance ("controllerType" key sits in route values)

I have a workaround on this, something like, but I really don't like it:

@{ Html.RenderAction("MyRegularAction", "MyRegularMvcController", new { controllerType = (object)null}); }


So my questions are:

1. Is it safe to replace ControllerTypeControllerFactory by DefaultControllerFactory from MVC framework? I follow standard MVC naming patterns and don't use IViewTemplateModelRegistrator directly, so default factory will be able to resolve controller by name.

2. What is purpose of ControllerTypeControllerFactory? In what cases controllerName will not match controllerType, so controllerType is really needed?

 

#82243
Mar 09, 2014 17:52
Vote:
 

Any comments?

:)

Still interesing in:

1. Is it safe to replace ControllerTypeControllerFactory by DefaultControllerFactory from MVC framework? I follow standard MVC naming patterns and don't use IViewTemplateModelRegistrator directly, so default factory will be able to resolve controller by name.

2. What is purpose of ControllerTypeControllerFactory? In what cases controllerName will not match controllerType, so controllerType is really needed?

#82298
Mar 10, 2014 13:08
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.