Static Variable vs View State

Discussion in 'ASP .Net' started by Nil, Apr 9, 2008.

  1. Nil

    Nil Guest

    Hi,
    I am facing problem with the huge Viewstate size(Using .NET 2.0).
    to improve the application performance,
    I am using Static variable to store view state data.
    Does anyone has other option to improve performance or what r drawback of
    using Static variable.

    Thanks,
    Nil
     
    Nil, Apr 9, 2008
    #1
    1. Advertising

  2. Nil

    Hans Kesting Guest

    Nil formulated on woensdag :
    > Hi,
    > I am facing problem with the huge Viewstate size(Using .NET 2.0).
    > to improve the application performance,
    > I am using Static variable to store view state data.
    > Does anyone has other option to improve performance or what r drawback of
    > using Static variable.
    >
    > Thanks,
    > Nil


    One thing to watch out for is that a static variable is visible to ALL
    users. So do not store user-specific information in it: you will
    overwrite the info of the other users.

    You can always set EnableViewState to "false" for all controls where
    you don't use it.

    Or maybe use the SessionPageStatePersister class (never used it myself)
    http://msdn2.microsoft.com/en-us/library/system.web.ui.sessionpagestatepersister(VS.80).aspx

    Hans Kesting
     
    Hans Kesting, Apr 9, 2008
    #2
    1. Advertising

  3. They kind of not interchangeable.....
    ViewState is per browser/request and static variable is the same for all
    users.
    You can look up on Google how to keep ViewState in a Session so it's not
    passed to browser back and force...

    But it's better to find another solution...

    George.


    "Nil" <> wrote in message
    news:...
    > Hi,
    > I am facing problem with the huge Viewstate size(Using .NET 2.0).
    > to improve the application performance,
    > I am using Static variable to store view state data.
    > Does anyone has other option to improve performance or what r drawback of
    > using Static variable.
    >
    > Thanks,
    > Nil
    >
    >
     
    George Ter-Saakov, Apr 9, 2008
    #3
  4. I agree with Hans. First you want to reduce the size of Viewstate as much as
    possible.
    Second, store it on the server with the SessionPageStatePersister. I wrote
    up a short article on this that illustrates how easy it is:

    http://www.eggheadcafe.com/tutorial...8-64dd33bfc2fe/keep-viewstate-out-of-pag.aspx
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "Nil" wrote:

    > Hi,
    > I am facing problem with the huge Viewstate size(Using .NET 2.0).
    > to improve the application performance,
    > I am using Static variable to store view state data.
    > Does anyone has other option to improve performance or what r drawback of
    > using Static variable.
    >
    > Thanks,
    > Nil
    >
    >
     
    Peter Bromberg [C# MVP], Apr 9, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kookey
    Replies:
    3
    Views:
    20,780
    Andrew Thompson
    Aug 20, 2005
  2. Patrick Hoffmann
    Replies:
    3
    Views:
    2,852
    Christian Jan├čen
    Aug 8, 2003
  3. CK
    Replies:
    1
    Views:
    689
    Galcho[MCSD.NET]
    May 23, 2006
  4. Parthiv Joshi
    Replies:
    1
    Views:
    753
    Samuel L Matzen
    Jul 6, 2004
  5. Nil

    Static variable vs View State

    Nil, Apr 9, 2008, in forum: ASP General
    Replies:
    2
    Views:
    194
    Anthony Jones
    Apr 9, 2008
Loading...

Share This Page