I've set a value into Viewbag.message
in my default HomeController and successfully display it in my Shared/_Layout.cshtml
.
After that I added another TestController and in the TestController view, Viewbag.message
seems to be null. May I know what's wrong with it.
Correct me if I'm wrong,from my understanding Viewbag.Message
should be available from all over the places?
ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view.
Below is a summary table which shows different mechanism of persistence. Credit:CodeProjectArticle