Reputation: 86
Is it possible to get the currently used ViewEngine
from the ControllerContext
or the ViewEngineCollection
? I would like to be able to do say the following ViewEngines.GetCurrent
. I know that I can make an extension for that method but I have no idea on how to implement this.
Upvotes: 5
Views: 2037
Reputation: 19220
You can use ViewEngineCollection
to look up the ViewEngine
associated with a particular view.
ViewEngineResult result = ViewEngines.Engines.FindView(controllerContext,
"myView","myMaster");
IViewEngine viewEngine = result.ViewEngine;
See here for more info.
Upvotes: 5