18

When will the values of the ViewBag be flushed or cleared ?

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
Naveen Vijay
  • 15,928
  • 7
  • 71
  • 92

1 Answers1

21

When you leave the view on subsequent request. ViewBag is created in the controller and it will live until the rendering of the view. In addition to this it is something that I would not recommend you using and replace it with view models.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928