Why would you ever use asp.net's ViewState storage object over the Session storage object?

后端 未结 8 2122
忘掉有多难
忘掉有多难 2020-12-23 17:55

Other than because session storage is session-global to more than one page, why would you ever want to use the viewstate to hold values?

It seems kind of ridiculous

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-23 18:40

    ViewState is essentially just a hidden input that must be uploaded to the server and parsed with each request. This field is typically populated automatically, often with the programmer blissfully unaware, and can grow quite large. For many sites that presents a problem, because even broadband users have very limited upstream bandwidth.

    On intranet sites where all the users have high-speed LAN access to the server but the ram available for holding session data is limited, it may make more sense.

提交回复
热议问题