Difference between viewbag and viewstate?

后端 未结 3 1096
遥遥无期
遥遥无期 2020-12-30 04:38

Is there a functional difference between ViewState in Webforms and ViewBag in MVC? They seem to be the \"same thing\". And can be used in the same ways. I ask because MVC pr

3条回答
  •  轮回少年
    2020-12-30 04:53

    the ViewBag doesn't get sent to the client ( Browser ). Its purely something to use transitioning from the controller to the View ( which is before its sent back to the client).

    In MVC, If you get a postback from that page, then you wont recover your "state", like Viewstate does, the only state you have is whatever you send to the browser, and whatever you send back.

提交回复
热议问题