Search code examples
asp.netlayoutasp.net-mvc-4master-pages

MVC4, two different masterpage


How can I use two different master page or layout in my web project with mvc4?


Solution

  • You create 2 different Layouts and then inside your view you can choose which layout to use:

    @{ 
        Layout = "~/Views/Shared/MyLayout.cshtml";
    }
    

    This can also be done inside the controller action rendering the view:

    return View("Index", "MyLayout", myViewModel);