This project is read-only.

change view engines after application load

Aug 27, 2013 at 5:52 AM
I'm writing a multi-tenancy based mvc application where I would like to have each tenant have its own separate view engine.

Currently the mvc framework caches the view engine list it retrieves from the Dependency Resolver after the initial call to load them, is there a way I can clear this list and have it loaded each time, (assuming my IOC container is actually handling the lifetime of these so I'm not neccessarily creating them on each request)

I've posted this to stack overflow here, and a similar question before but never got any answers, and am not really expecting much from the current question I have.

Does anyone have any advice on how I might go about this?

I can link in samples to reproduce the behaviour if this helps at all.
Sep 1, 2013 at 12:44 AM
Hi there,

I don't believe that this is supported in any simple way - it's not a scenario that we had considered while designing this part of the system.

If I had to guess, I think the closest way to achieve this would be to register a single custom view engine that delegates to other view engines as necessary. You'd have to be careful about how to implement any caching behaviors because the dynamic system has to be aware of how to invalidate the caches.

Sep 1, 2013 at 8:48 AM

Yeah I've managed to cobble together a custom view engine that delegates out to others as you say, but I'm not 100% confident re the caching behaviour of it.

I'd love to see some better support or hooks for multi-tenancy in mvc (ie viewengines and controllerfactories), is it worth raising a ticket or something to discuss some of these extension points further, I'd love to try and contribute if its something that would be wanted.
Sep 5, 2013 at 5:32 PM
You can log an issue in the issue tracker and we can see how many votes it can get. If you do so, please provide specific use cases and scenarios. An alternative that would reach a broader audience would be to consider posting a question on StackOverflow and see what the community at large thinks, or if perhaps they already have good ideas on how to solve this problem.