Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net MVC get current viewengine

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.

like image 227
Guldan Avatar asked Sep 11 '11 14:09

Guldan


1 Answers

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.

like image 180
TheCodeKing Avatar answered Sep 28 '22 05:09

TheCodeKing