I have the default _ViewStart.cshtml in my /Views folder. I\'d like to be able to access my ViewBag object so I can set the default title for all my views.
However,
In short... Use the controller's view bag.
ViewContext.Controller.ViewBag.MyVar = "myVal";
and
@ViewContext.Controller.ViewBag.MyVar
===============================================================
There is good information here: http://forums.asp.net/post/4254825.aspx
===============================================================
Generally, ViewData["StoreName"] is same as ViewBag.StoreName
Also, Controller.ViewData["StoreName"] = Controller.StoreName = ViewContext.Controller.ViewBag.StoreName =ViewContext.Controller.ViewData["StoreName"]
But every view and partial view gets its own instance of viewdata.
http://jeffreypalermo.com/blog/viewdata-mechanics-and-segmentation-excerpt-from-asp.net-mvc-in-action/
===============================================================
There is a another solution here: https://stackoverflow.com/a/4834382/291753
===============================================================