I am using MVC 3 with the Razor view engine. I want to set some values in the ViewBag inside a Partial View and want retrieve those values in my _Layout.cshtml. For exampl
I this is what page data is designed for. Pop this into your view.
@Page.somePropertyName = "Whatever you want";
And then access it in your layout view. Be sure to check that its not null first.
@{ if(Page.somePropertyName != null) { //Do stuff } }