I’m using ViewBag.Message with the same message several times into the methods on the controller.
It is possible to declare ViewBag.Message on the top of the class, so can be used in the whole controller without repeat the code?
I’m using ViewBag.Message with the same message several times into the methods on the
Share
Assuming Razor syntax you can achieve this with.
then pageMessage is a local variable available to the page, for example:
EDIT
ViewBag is a dynamic object which is a member of the Controller base class so to just specify this once in the whole controller you could put something in your controller constructor.