'Per user' variables

G

Guest

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?
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top