Add custom / shared location to the Umbraco View Engine default search patterns
Hi all,
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.
Add custom / shared location to the Umbraco View Engine default search patterns
Hi all,
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:
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:
or
Can you please help me with the best way to resolve this without resorting to Multiple duplicative Master.cshtml files ?
Thanks
Terry Clancy
ClanceZ
Hey Terry
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 ?
Like this ?
Dave
And u can use _ViewStart.cshtml to add (should allso be placed in ~/views/Shared/)
is working on a reply...