I’m extending WebFormViewEngine and when I override FindView and debug at runtime, the masterName parameter seems to always be an empty string.
What does the parameter masterName represent?
MSDN is no help: “The name of the master”.
public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
Thanks.
It is the name of the requested master page (layout file), if the developer specified one. One of the overloads to the
View()method (and thus some of theViewResultproperties) is the name of the master page to use. For example:The master name that you get will most often be empty because it is relatively rare to specify a custom master page from within the controller. In most situations the view will itself choose an appropriate master page. One case where I’ve seen it done from within the controller is if there are special circumstances, such as browsing from a mobile device, where an alternate master page is useful.