I am writing cms with MVC, which is used as the main mechanism for creating pages.
I am going well, but I need the opportunity to create a unique razor template for each site and, possibly, for each presentation, if I need to.
My rules are that each project must have a unique code that is associated with a URL.
Assets for each project site are stored in such a way that the location refers to the project.
Thus, the assets associated with project C0001 will be stored in assets\C0001\ and for C0002: assets\C0002\ , etc.
What I wanted to do to keep things in order was to have razor patterns associated with the project located at assets\[ProjectCode] , but the problem is that I get a ViewBag not existing in context error message ViewBag not existing in context .
So this will not work:
Layout = string.Concat("~/assets/",ViewBag.ProjectNumber,"/_Layout.cshtml");
Where the following will be shown:
Layout = string.Concat("~/Views/Shared/_",ViewBag.ProjectNumber,"Layout.cshtml");
I assume the first layout does not display because it is outside of the known search areas for views? But since I say where the file is located, I donβt see what is the problem?
I am happy to work with the code shown in example 2, but it can mean that after many project sites are launched, viewing sections will be very busy.
Just wondering if there is a reason Views should exist in the Views directory?