DEV Community

loading...

Discussion on: Kentico 12: Design Patterns Part 6 - Rendering Meta Tags in Kentico 12 MVC

Collapse
oliverfurmage profile image
oliverfurmage

@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;

@{
    ViewBag.Title = Model.Page.DocumentName;
    Layout = "~/Shared/Views/_Layout.cshtml";
    ViewBag.MetaPageDescription = Model.Page.GetInheritedValue("DocumentPageDescription");
    ViewBag.MetaPageKeyWords = Model.Page.GetInheritedValue("DocumentPageKeyWords");
}
Thread Thread
seangwright profile image
Sean G. Wright Author

Interesting! Good to know there is a solution like this 🧐.