Setting the layout from another file gives compilation errors (ASP.NET MVC3 / Razor)

I have a standard ASP.NET MVC3 application. In _ViewStart.cshtml, I had:

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

Everything worked and life was good. Now I want to move the layout to a directory that can be changed at runtime; sort of:

@{
    Layout = "~/Content/Themes/" + SomeClass.FolderName + "_/Layout.cshtml";
}

(Where potentially I would call SomeClass.FolderName = "blah"in my code.)

Inserting a copy of the old Shared/_Layout.cshtmlinto the directory specified SomeClass.FolderName, unfortunately, gives me several compilation errors, such as ViewBag, Urland Htmlnot existing (but, oddly enough, User.Identitystill available).

What am I missing and how can I do this?

: , web.config /Views , , - - CSS 404 (, {SomeClass.FolderName}/site.css).

+3
1
+5

All Articles