Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ViewState vs SessionState
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00761040
Message ID:
00761169
Vues:
38
One recommendation is to make sure you turn off ViewState on any controls that don't need it. That way you cut down on the extra unneeded information marshing back and forth.

The other recommendation would be if you don't need to refresh your data once you retrieve it, make sure you wrap the filling of the DataSet in a if clause to test the IsPostback property of the page. That way you only refresh the DataSet the first time the page is loaded. This will help performance as well.

>Hey Cathi!
>
>Thanks for answering. The reason for needing to keep the DataSet information is because, although I'm only using one page, I'm displaying different objects (UserControls) on that page, depending on what the user wants to see. The DataSet contains information that's displayed over several different UserControls, so it made sense to me to keep the state of the DataSet once it's retrieved.
>
>Sounds like I'm on the right track. Thanks!
>
>~~Bonnie
>
>
>
>>Hi Bonnie!
>>
>>Based on the information you are providing where your DataSet will contain very few records, I would recommend using ViewState. You will be passing back and forth the information but it since your data is so small, it shouldn't really affect performance. Are you needing to use the DataSet on different pages or is it isolated to this one page? This could effect your decision. SessionState is used for referencing objects during the entire session. ViewState is for the page, unless the objects are too large to marshal back and forth or they can't be serialized.
>>
>>>Hey gang,
>>>
>>>I'm just starting to research this topic now, and I'd like some input from some of you guys who are doing one or the other. Pro's and con's of each methodology would be nice.
>>>
>>>I'm trying to decide how to persist my DataSet. From what I've read (and remember, I've just started researching this), it seems that if you don't have a lot of data in your DataSet, then maybe saving the DataSet to the ViewState might be ok. In the WebForm I'm working on now, I am dealing with a fairly small DataSet (a few tables with not a lot of columns, mostly having one row in each table, some might have multiple rows). The other option seems to be storing the DataSet server-side in a SessionState. (As long as, if I understand it correctly, you can overcome problems with Server Farms.) It seems that it's best to avoid that unless needed (which would be if the data is too large to store in a ViewState).
>>>
>>>Am I making correct assumptions? Anyone have any practical experience with this? What are the rest of you guys doing?
>>>
>>>Any input would be much appreciated!!
>>>
>>>TIA,
>>>~~Bonnie
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform