I encountered a problem while using my Castle Windsor Factory controller with the new RenderAction method. The following error message appears:
A single instance of MyController cannot be used to process multiple requests. If you are using a custom Factory controller, make sure it creates a new controller instance for each request.
This is the code of my factory controller:
public class CastleWindsorControllerFactory : DefaultControllerFactory { private IWindsorContainer container; public CastleWindsorControllerFactory(IWindsorContainer container) { this.container = container; } public override IController CreateController(RequestContext requestContext, string controllerName) { return container.Resolve(controllerName) as IController; } public override void ReleaseController(IController controller) { this.container.Release(controller); } }
Does anyone know what changes I need to make to make it work with RenderAction?
I also found that the error message is a little strange because it speaks of several requests, but from what I can tell, RenderAction does not actually create another request (BeginRequest does not start again).
source share