Skip to content

View state

kavita

Asked Jul 27, 2007, 3:01 AM EDT1 answer
Share
LinkedInX
hi this is kavita I simply want persist 5-8 variable value on same page which viewstate management techineque is best in this situation. viewstate,cookies,cache,session etc please give me suggestion.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    If you are only concerned with persisting variables in the same session of a particular user (a session being within the context of a browser session on a single client), use the session state

    Session["var1"] = 50;  // for example

    Sessions has an advantage over Caching in that you can use it on web farms because they support single point storage and can be configured to store in a sql server database.

    Caching stores at the application level and is similar to the Application store. Each item can be accessed by multiple users across multiple sessions.

    Cache takes advantage of concepts such as scavenging,  and sliding expiration which tries to keep the most actively used data in memory.  If you want better performance for lots of data, I would use caching. 

    So the decision you need to make is if the 5 variables are only persistent per browser session use the Session state otherwise if it needs to persist for everyone as long as the application is running,  use the Application state.
    0