Question

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

Was it helpful?

Solution

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");
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top