1

我有一个业务实体,我在单个 aspx 页面上使用它。这个页面有很多控件,因此会发生很多回发。我想知道,是否建议将此业务实体存储在视图状态(因为我需要在单个页面上)或会话(因为如果实体有更多数据,它将增加我的页面大小并因此增加网络延迟)。

4

1 回答 1

0

View State:

Why do you use ViewState? It makes your page heavier. Hence you will end up with poor response time.

Session - From my view, you can use it here but make sure you remove it once it is not necessary or no longer referred. As you start storing objects in Session IIS will store those in in-memory/in proc (default) will get increased and IIS processing will be slower over the period of time. If your server has good memory 32GB Ram and other capabilities to handle , you no need to worry

HttpContext

HttpContext would be the much better way of storing an object between a single round trip(request/response). So you can prefer this over a session as it will be availble only for a current request, no need to worry about removing an object like session handling, as it will be automatically cleared once the request completed.

Hope these things would be helpful to you!

于 2012-12-11T06:22:00.840 回答