In my MVC project has 2 Areas which is Admin and Client and I need to dynamic config Layout for Client side, In _ViewStart (in client) file will set layout for all of client page.
Layout = "~/Views/Shared/_Layout.cshtml";
So if we need to change client layout we can change Layout path of cshtml file in _ViewStart file right? I cant find how to change inside ViewStart file or Is there another solution in this case.
Thanks for your Help 🙂
Remember that anything within the
@{ ... }is treated as code. So, it should be a simple matter of placing a condition in there to change how it’s inherited:Though you’re probaby better off looking at Themes (and have an admin/user theme). Alternatively, you can make your
_Layout.cshtmlsmarter and have it handle the different views based on conditions as well.See Also: MVC3 Razor – Is there a way to change the Layout depending on browser request?