This is really not an answer to your questions, but you might want to
refactor the code design.
Session variables are nothing more than "fancy" global variables. And
just like the way you might avoid the use of global variables in a normal
application, the same reasoning should be applied to session variables.
That is not to say that global/session variables are not important -- they
have their place -- but it is important to be able to rationalize why you
use them rather than just saying something like "they are convenient."
Having said that, here is my take on your question.
What do you mean "keep track of"? Do you mean being able to know what
parts of code are setting a particular variable or simply that you want a
list of session variables in use? In the past, if I wanted to use session
variables, I have often encapsulated the getting and setting behind some
other class that centralizes the action. Essentially there would then be
only one place in the entire code that sets or gets the value directly
from the session (that is there was only one call to Session["..."]). By
doing this, you can 1) centralize access to the variable, 2) be able to
group related session variables together, and 3) Be able to enforce
consistency like suppose that variable "foo" could only be set if variable
"bar" is null, then properties could help enforce that.
Alan Wang said:
Hi there,
Once my application gets complicated and complicated. I found it's really
hard to keep track of Session value I am using in my asp.net application.
I am just wondering if anyone have any experience on how to keep track
of session value. Any help it's appreciated.
Thanks
Alan