views:

43

answers:

1

I have a couple different userTypes (Admin, User) and a MasterPage for each. I am beginning to create some Views that will be used by both userTypes where i would like to assign the MasterPage programmaticly (based on _currentUser).

Possible?

thx

+2  A: 

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");
  }
}
David G