Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

Keep track of Session value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan Wang - 28 Oct 2005 19:19 GMT
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
Peter Rilling - 28 Oct 2005 19:37 GMT
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.

> Hi there,
>
[quoted text clipped - 6 lines]
>
> Alan
Alan Wang - 28 Oct 2005 20:02 GMT
>>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?

Probably both. Sometimes I just lost keep track of where I used this Session
variable and why use this session variable especially when you didn't touch
that code for a while. For regular variable,  I can use "go to definition"
and then be able to find where I defined this variable and data type. But I
can't do it with Session variable. That's something really bothers me. Do
you have any solution or suggestions for that.

Thanks in advanced

Alan

> This is really not an answer to your questions, but you might want to
> refactor the code design.
[quoted text clipped - 30 lines]
>>
>> Alan
Peter Rilling - 28 Oct 2005 20:23 GMT
When I need to find session variables, I simply search the whole project for
the string "session[".  Then I catalog all the variables that I find and
where they are accessed.

>>>Do you mean being able to know what parts
> of code are setting a particular variable or simply that you want a list
[quoted text clipped - 51 lines]
>>>
>>> Alan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.