Return to Snippet

Revision: 65753
at January 15, 2014 02:13 by lance


Initial Code
@{
    string currentController = ViewContext.RouteData.Values["controller"].ToString();
    if(currentController == "PCA" || currentController == "pca")
    {
        Layout = "~/Views/Shared/_LayoutPCA.cshtml";
    }
    else
    {
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
}

Initial URL

                                

Initial Description
How to load a different layout page for specific controller in case you need to change includes etc. Add to _ViewStart.cshtml

Initial Title
Load different layout page based on controller

Initial Tags

                                

Initial Language
C#