Is there any way to get the file name (or view name) being rendered from an extension method. Something like :
public static string Something<T>(this System.Web.Mvc.HtmlHelper<T> helper, int value)
{
string viewName = ...; // ???
...
return someValueFromViewName;
}
** Edit **
The suggested question's answer :
var webPage = htmlhelper.ViewDataContainer as WebPageBase;
var virtualPath = webPage.VirtualPath;
does not work, and is not an answer to this question. I need the script being rendered at call time. If it is a partial, I need that partial name. Those two lines only returns the view being rendered from the controller, and not necessarily the view script being rendered at call time.
** Edit 2 **
These also ddo not work. They all return the same value; the controller's view script and not the view script (partial) calling the extension method.
var view = htmlhelper.ViewContext.View as BuildManagerCompiledView;
var virtualPath = webPage.ViewPath;