ViewBag in static method of controller
I am new to mvc and I load ViewBag in a method of controller as,
HomeController: Controller
{
Public ActionResult Index()
{
loadViewBag();
return View();
}
public void loadViewBag()
{
ViewBag.aaa = "something";
}
}
It works fine.
What is my problem is, Now I want to call loadViewBag() method form
another controller( say Account) so that I can reuse same method and need
to make loadViewBag() method static due to some static variables as:
public static void loadViewBag() If I make loadViewBag method static,
there appear error on ViewBag " An object reference is required for the
non-static field, method, or property
'System.Web.Mvc.ControllerBase.ViewBag.get' ".
Is there any solution/suggestion.
Thank You.