Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have various MVC views associated with various controllers.
Each view is in a folder with the name of the Controller (without "controller") .
All those views need to use the SAME "Master.cshtml" layout file. That file is currently located in ~/Views/
This is not normally an issue because in general my MVC pages are included in normal Umbraco pages as Partial Views and the Normal Umbraco page takes care of referencing the "Master.cshtml" layout file.
However for some pages such as http://www.mysite.com/users/Myusername I use Custom MVC Routes as described at https://our.umbraco.org/documentation/reference/routing/custom-routes.
In the case of pages using Custom MVC Routes I return from the controller as follows to indicate the name of the Master layout file:
return View("ViewProfile", "TTMaster", viewProfileViewModel);
But my ~/Views/Master.cshtml is not found.
I tried the approach detailed at http://www.ryadel.com/en/asp-net-mvc-add-custom-locations-to-the-view-engine-default-search-patterns/ but as indicated by my comments at the bottom of that page it did not work, it appears this is because that neither of the following work in Umbraco whereas it does in a standard ASP.Net MVC app:
var razorEngine = ViewEngines.Engines.OfType<razorviewengine>().First();
string EngineName = ViewEngines.Engines[x].ToString();
Can you please help me with the best way to resolve this without resorting to Multiple duplicative Master.cshtml files ?
Mvc has a concept Called Shared views and all i have to do is create a folder Called Shared in your views folder an put i Master there
Why don't you put a layout directive in you view it self ?
Layout = "_Master.cshtml";
Like this ?
And u can use _ViewStart.cshtml to add (should allso be placed in ~/views/Shared/)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted