Using EnableFeatures(), DisableFeatures() inside a module

Topics: Writing modules
Jan 15 at 6:48 PM
Edited Jan 15 at 6:51 PM
I have an /Admin/MyModule page with a button on it, when pushed it calls an Ajax Controller which calls:
_features.EnableFeatures(new[] {"Orchard.Search.MediaLibrary"}, true);
It seems to work, but then the next page load fails with a Lifetime scope issue. The site then hangs.

I tried wrapping it in a lifetime scope, but it still fails on the next page load.
using (new TransactionScope(TransactionScopeOption.RequiresNew))
{
    _features.EnableFeatures(new[] {"Orchard.Search.MediaLibrary"}, true);
}
Is it possible to call code like this in a controller, or does it HAVE to be in a Migration?
Coordinator
Jan 15 at 6:52 PM
Can't do it right now by myself but you could look at what the Features controller is actually doing when it enables features. Use the exact same code and it should just work.

Another location to look at is in the Features recipe step which can do it too.
Jan 15 at 11:59 PM
Edited Jan 16 at 1:03 AM
I looked at both Recipe and Features controller and they are both simply calling the same method that I'm calling.

I think it was something colliding with SignalR. I removed that and now it seems to be working.