'Per user' variables

Discussion in 'ASP .Net' started by =?Utf-8?B?Qm9uag==?=, Apr 13, 2004.

  1. H
    In creating an ASP.NET page in C#, I notice that it seems very efficient with regards to things like what I would call 'pooling', for instance: I have a string variable that the Page_Load procedure checks and if it is null/empty, it loads the value from the registry. Now I notice the sub-procedure to actually get the value out of the registry only seems to get called the first time the page is viewed since the last rebuild, even if you close the browser and open the page up again on another client, the variables don't seem to get cleared. Another thing I notice that I have a datagrid control that dynamically gets data from a database using an SqlConnection connected to SQL Server in the Page_load event, but when I navigate to the page for the second time since rebuild (even on a different terminal) the display of the data is instant, like it's cached the page - but even if the data has changed. I presume this must be because it's maintained the connection and that it is the actual making of the connection rather than the running of the SQL query that takes the time, since it is a stored procedure that is very light on resources

    But, this brings me to ask

    What if I *want* some variables to be cleared - i.e. I'm not really sure about where I should be drawing the line as to what defines a 'session', but supposing I want a variable that is 'per session', i.e. that resets itself when the user logs off from the site/navigates to a different site/closes the browser?
    =?Utf-8?B?Qm9uag==?=, Apr 13, 2004
    #1
    1. Advertising

  2. Session variables could be your answer(e.g. myStr = Session(strName)). At logoff, you could set each one to nothing

    Please note, though, Session variables should be used sparingly. They are saved on the server, not the client, and if there is 'heavy' traffic, many Session variables used by many users can harm performance
    =?Utf-8?B?bWtsYXBw?=, Apr 13, 2004
    #2
    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. =?Utf-8?B?S01aX3N0YXRl?=

    Quick one - Is SESSION per browser instance or per IP Address?

    =?Utf-8?B?S01aX3N0YXRl?=, Apr 4, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    5,864
    gerry
    Apr 10, 2006
  2. Razvan
    Replies:
    1
    Views:
    405
    tony vee
    Sep 10, 2004
  3. Replies:
    5
    Views:
    2,521
  4. Replies:
    0
    Views:
    340
  5. chris brat
    Replies:
    1
    Views:
    617
    chris brat
    May 10, 2006
Loading...

Share This Page