Вопрос

I use a lot of ASCX user controls in my projects. These controls utilize update panels to update their contents. To persist data across partial post backs (ie, when update panel updates) I store all the controls data in a session. For example, I might have a control that uses a CheckBoxList. When a user checks a box from the list, it causes a partial postback (to do some logic) and the update panel fires. Because the panel is updating, I would lose all data between post backs, except that I store this data in a session. This way, when the control reloads, I can take the data and restore the checkbox list. My sessions typically consists of lists of objects.

My question is: is this the best way to persist data? What are some possible problems I might not be accounting for? I was told that if multiple people are using this at the same time (as the lists of objects are large) IIS may run out of memory and crash.

Thanks for any help

Это было полезно?

Решение

It's hard to say if this is "the best way to persist data" for your particular project. I can however address the "possible problems" part of your question.

Session state is stored in-memory by default, which means that you will be using additional resources on your server. Session variables can be created on the fly and do not require you to dispose of them explicitly which can lead to more overhead. So yes you are correct that using sessions for much of your functionality will most likely mean using up more resources (CPU and Memory). Whether it will "run out of memory and crash" is a matter of the load vs. the server.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top