Having populated a ViewData, is it possiblie to use that ViewData collection from multiple action methods within a controller without the need to repopulate it?
Having populated a ViewData, is it possiblie to use that ViewData collection from multiple
Share
No,
ViewDatais not intended to be used that way. It is only a temporary shared storage between a controller action and a view. It allows the controller to pass some model to the view. From design perspectiveViewDatashould not be read by the controller action, it should only be written to.You could use the
Sessionobject if you want to store objects between multiple requests orTempData(which internally uses Session) to store data between two requests.