Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
I believe for Template pages you need to specify a Layout, which means whatever you've done for your primary site _Layout.cshtml you will need to do in the Template page's layout as well to get Site Meta information to work correctly.
ViewBag should work fine even in this scenario (however I haven't actually tested it).
Use MVC layouts with the template view for any shared output code (based on your requirements, you can use your site's main layout, a dedicated layout for page templates, etc.).
This can be done through an explicit definition at the top of the Razor file:
I had already set the Layout of the template file and I could see elements from my _Layout file (for example the header), however it seems to me that the ViewBag variables set in the controller were not being passed through.
To get round this I decided to do the following on the template file;
Lead Product Evangelist @Kentico, Founding partner @craftbrewingbiz. love to learn / teach web dev & software engineering, collecting vinyl records, mowing my lawn, craft 🍺
@oliverfurmage
I believe for Template pages you need to specify a Layout, which means whatever you've done for your primary site
_Layout.cshtml
you will need to do in the Template page's layout as well to get Site Meta information to work correctly.ViewBag
should work fine even in this scenario (however I haven't actually tested it).On the docs page for MVC Page Templates it mentions needing to specify a layout for the template Razor file.
This can be done through an explicit definition at the top of the Razor file:
Or through a
_ViewStart.cshtml
file to set the layout for an entire subfolder.@seangwright
I had already set the Layout of the template file and I could see elements from my _Layout file (for example the header), however it seems to me that the ViewBag variables set in the controller were not being passed through.
To get round this I decided to do the following on the template file;
Interesting! Good to know there is a solution like this 🧐.