![]() |
|
|
|
#1 |
|
does anyone know the diffrance between
ViewState["variable"] and Session["variable"] and when to use each of them ? hisham |
|
|
|
|
#2 |
|
Posts: n/a
|
ViewState is posted back (round tripped) to the
Server/Browser and the data is contained in a hidden control. SessionState is stored on the server and is not posted back (unless it is required to be displayed of course payload, security, Server loading, data type (ie Viewstate is serialised and best suited for 'simple' data types cf SessionState which can handle any .Net datatype. Both are browser independent. That's about all I can recall, Andrew >-----Original Message----- >does anyone know the diffrance between > >ViewState["variable"] > >and > >Session["variable"] > >and when to use each of them >? > >. > Andrew |
|
|
|
#3 |
|
Posts: n/a
|
ViewState is state that is stored for a particular ASP.NET WebForm. It holds values between postbacks for a page. ViewState will be lost once you visit another page and return. Session state is a per user way of storing information for that user, like UserID, FirstName, LastName, etc. It can be used to store just about anything unique to that user.
Both come with a penalty hit, however. ViewState is encrypted and sent to the browser in a hidden field "__VIEWSTATE", so if you have a lot of controls on a page that store their state in ViewState, this field can be bloated and increase the size of the page download. This can be trimmed by setting EnableViewstate = False for any control or page if you wish. Session state, has 3 different methods of storage: InProc, StateServer, SQL Server. InProc uses the in process memory currently running the ASP.NET application at the moment. If you make a change to your web.config or upload a new .DLL, all session is lost. StateServer uses a separate Windows Service to store state outside of the ASP.NET application. Therefore, if you update (like before), session is not lost, except for a server reboot (This is what I/my company use). Both of these scenarios can increase the amount of memory that is used, so you must be cautious to what you place in session. Lastly, storing state in SQL Server alleviates the headache of web farms and server restarts because it uses SQL Server to store its state. The only penalty you will see here is the constant flow of data between your webserver & sql server. I hope this helps! Matt Hawley, MCAD .NET http://www.eworldui.net does anyone know the diffrance between ViewState["variable"] and Session["variable"] and when to use each of them ? Matt Hawley |
|
|
|
#4 |
|
Posts: n/a
|
I think the answers to this question were great. However, with about 2
seconds on MSDN you got enough to answer this question. What is the line between spoon feeding and helping? I don't want to be an ass but do you really want to work with someone who can't figure out the difference between these two things? I know this has been hit upon many times, I'm just getting frustrated by questions like this in this newsgroup and other newsgroups. Is it just me? I'll go away and shut up if so. --Al MSCD, MCSD.NET, MCDBA and someone who TRIES to answer my own questions through available sources first, breaks down my attemps in my posts, and then asks for input. "hisham" <> wrote in message news:20d301c4279b$6d263090$... > does anyone know the diffrance between > > ViewState["variable"] > > and > > Session["variable"] > > and when to use each of them > ? > Al Manint |
|
|
|
#5 |
|
Posts: n/a
|
hisham wrote:
> does anyone know the diffrance between > > ViewState["variable"] > > and > > Session["variable"] > > and when to use each of them > ? OTOMH Viewstate belongs to the view (e.g. the current page), SessionState to the current session Paul Robson |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) | msandlana | Software | 0 | 04-25-2008 06:37 AM |
| ASP.Net Project Structure Question | koraykazgan | Software | 0 | 08-10-2007 08:23 AM |
| ASP.NET 2.0 application does not run in WIN2k3 | johnfraj | Software | 0 | 04-19-2007 08:27 AM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | God | DVD Video | 3 | 04-25-2005 04:19 PM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | Filthy Mcnasty | DVD Video | 0 | 04-25-2005 04:29 AM |