I wrote an extension method for HtmlHelper, which is called from the main page, which must access the ViewBag in order to get the information specified by this page.
This is the method signature:
public static string BuildFavoritesTitle(this HtmlHelper htmlHelper) { }
I noticed that inside the method, if I access
htmlHelper.ViewContext.ViewBag
I get an empty ViewBag, but if access
htmlHelper.ViewBag
I get the "correct" ViewBag. Correctly, I mean a ViewBag with elements added to the inner page.
I like to know what is the difference, why is there more than one ViewBag?
source share