DEV Community

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

oliverfurmage profile image


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");
Enter fullscreen mode Exit fullscreen mode
Thread Thread
seangwright profile image
Sean G. Wright Author

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