Re: Need Advice on Viewstate

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Kevin Spencer (kevin_at_takempis.com)
Date: 03/01/04


Date: Mon, 1 Mar 2004 09:50:26 -0500

ViewState and SessionState both exist for good reasons, and there are times
when using one or the other is a good idea. ViewState doesn't take up server
resources (memory), but it can slow down response time from the server due
to the amount of data being transmitted to the browser, and is only
persistent at Page scope. That is, ViewState only lives as long as the
current WebForm is loaded and posting back to itself. Once the user
navigates away from that Page, ViewState is lost. SessionState lasts an
entire single user Session, and is persistent across Pages. It does consume
some server resources during its lifetime, and can time out. Keeping these
in mind, and handling their eventualities should make SessionState a viable
storage persistence medium for objects with Session scope.

-- 
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"jenn" <anonymous@discussions.microsoft.com> wrote in message
news:39553F97-D67F-467C-B96F-E951D6FCA99D@microsoft.com...
> Hi,
>
> I was using Sessionto persist datatables, but now I don't think it's good
idea to do so as Session can cause overhead on the server (as the number of
users grow), so I use ViewState to store the datatables instead.
>
> I'm wondering what are the disadvantages of using ViewState against
Session, beside the fact that the former slows the rendering of HTML as well
as the data is visible to the user.
>
> Are there other issues I should be concerned about, such as memory
overhead on the server, as the number of users grow? Are ViewState values
unique to a session/page, or are they of application level? Is there a need
for ViewState clean up (sounds silly because I think the answer is no, but I
want to make sure)
>
> Thanks in advance for any reply.


Relevant Pages

  • Re: aspnet_state.exe Internals Info Needed
    ... Last night I tried runing with server side viewstate off, ... was fine, the processor was much less under pressure, and the memory usage ... All being persisted to the session. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: viewstate
    ... if the the data needs to be saved for a single page between postback then ... > ViewState is on the page. ... It travels between server and client. ... Session is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Variables defined in the partial class - ASP.NET 2.0
    ... - with session you'll use up more memory on the server (you could also use ... - with viewstate you'll have a bigger page and hence a bigger transfert time ... my personal preference would rather to keep this server side ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Going sessionless (and cookie limitations)
    ... that the benefit of using cookies to host all session information rather ... eliminate the traffic going from the web servers to the state server or SQL ... only instead of spawning network overhead behind the firewall ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session state and multiple windows/frames
    ... different sets of ViewState. ... session, ... > heavy use of 3rd-party controls, popup windows and frames (not my design ...
    (microsoft.public.dotnet.framework.aspnet)