If I have a base controller e.g. StaffBaseController can I cause any ViewResult result returned to have a default Layout page? e.g StaffLayout.cshtml. I know I can use a _viewstart file in the folder structure to set a default layout. Just wondered if I could set it on my base controller class.
If so how do I do it? Would it be possible to override the default in certain situations?
Thanks
Graeme
Greame,
you can try something like this in your base controller (this is taken from an aspx project but should be tweakable for razor):
so in that example, the initially defined master template name (Site.Master) value gets changed to ‘Shareholder’ (Shareholder.Master) if the user isn’t an admin user.