Can the MasterPage be designated from the Controller?
I have a couple different userTypes (Admin, User) and a MasterPage for each. I am beginning t开发者_开发百科o create some Views that will be used by both userTypes where i would like to assign the MasterPage programmaticly (based on _currentUser).
Possible?
thx
Use Controller.View() overload
return View("MyView", "MyMaster");
in your controller to determine the view and the master page it should use.
public ViewResult Index() {
if (User.IsInRole("Admin")) {
return View("Index", "AdminMaster");
}
else {
return View("Index", "DefaultMaster");
}
}
精彩评论