I have a class includes.vb that holds some variables (sharing them with other pages) like:
Public Shared pageid As Integer = 0
I then have a function that does some work with these variables returning them with values;
Return pageid
When I step through the code, the variables have values (while stepping through the function), but when they are returned to the page, they come back null.
Do they loose value everytime a page is loaded?
Can you suggest an alternative method?
Thanks a lot.
You should use probably Session variables.
and access it every time you need.
Not a best practice but if you want to be even stricter, you can use specific application variable for every session so that if the user returns after a day to the website, it still not lost (as long as you haven’t done an iisreset).
To overcome iisreset will be an even bigger overkill, you can save the value to a file/DB and retrieve it everytime you want. (Please don’t do that!!)
Maybe this can explain further:
http://codeforeternity.com/blogs/technology/archive/2007/12/19/handling-asp-net-session-variables-efficiently.aspx