I have a specific ViewBag property that I would like to set at the ViewStart level. Ideally, I would like to be able to override that property on a page basis, if necessary. Is this possible? If so, how do I access the ViewBag property within a ViewStart page?
Share
There are two way to do this:
Use the
PageDataproperty (it’s something more applicable to ASP.NET WebPages and seldom used in MVC)Set:
Retrieve
Try to find the view instance (the code is a bit dirty, but it does give you access directly to
ViewBag/ViewDataSet:
Retrieve: as per usual