Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Session Variables and Static Variables

Reply
Thread Tools

Session Variables and Static Variables

 
 
cobus.lombard@gmail.com
Guest
Posts: n/a
 
      03-23-2006
I have found it very easy to have a Helper class that has static
members which access Session Variables. For example:

public class HelperClass
{
public static doCustomer CurrentCustomer
{
get
{
if(HttpContext.Current.Session["Current_Customer"] == null)
CurrentCustomer = new doCustomer();

return (doCustomer)
HttpContext.Current.Session["Current_Customer"];
}
set
{
HttpContext.Current.Session["Current_Customer"] = value;
}
}
}

Is this thread safe? Will each user of the Application still have his
own instance of doCustomer, even though it is accessed via an
Application Wide static member? What is the best practice regarding
Thread Safety, Session Management and Static Members?

Thanks

 
Reply With Quote
 
 
 
 
cobus.lombard@gmail.com
Guest
Posts: n/a
 
      03-26-2006
Anybody?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I access non-static variables from static funcition? Neviton C++ 9 09-17-2007 10:21 PM
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= ASP .Net 4 04-11-2007 04:52 PM
Static and Session variables Varangian ASP .Net 0 03-27-2006 11:21 AM
Instantiating a static class( Class with all static members - methods and variables) SaravanaKumar Java 6 10-19-2004 08:20 AM
How can I "know" the difference between a session timed out and a session that did session.abort? Jazzis ASP General 2 09-23-2003 07:16 AM



Advertisments