• работа net хозяйке_на_заметку Session vs ViewState

    Session and viewstate both have different uses and can be used based on the scenario, they do not have to be exclusive or. you could use both in a web application.

    As you have allready noticed, viewstate is used only for one page and can not be accessed by a different page. Lets say that's the case

    If the data you store in the viewstate is not large enough to cause performance headaches, go with viewstate, if not session is your best friend. Also, notice that session has its share of problems too. If you store too much data in session and you create many sessions in a short period with many of your concurrent users, you would be killing your server. Remember when you use "InProc" session mode, all the session data is stored inside the application domain where your application is running, which in turn runs inside the aspnet_wp appdomain. And it has only certain memory it can use. After that the worker process gets recycled and you would lose all the sesson data.

    Ofcourse, you could use other modes of session, like StateServer mode and SqlServer mode. But they are slow compared to the "InProc" session mode

    So, it depends on your scenario. There is no clear winner here.

Replies (0)