views:

52

answers:

1

I have an web application written in ASP.NET (FW 3.5) (along with some VBScript, this is a legacy app) that uses a utility class in the backend that logs error.

I need to log several values that a user has entered in the front-end. Since the utility class has no access to the front end (or any HTTP services), i created a singleton class within the utility namespace that my front end UI can access and store information about the user.

I guess more specifically, I am wondering if there's a way to store session variables that can be shared across the web application and web services through a class referenced by both of the application and web services. For example, I have an error handling class that is used by both instances that required information about the user. Is there a way to create a per-session singleton to hold that information, so that my error class will have access to the user info? or is this not possible - that i'll need to pass the information around as they are needed?

+1  A: 

If your singleton implementation uses a Shared variable, your instance will be unique within a single AppDomain.

That said, I would try to avoid using a Singleton simply to facilitate passing data to your utility class.

Larsenal
what would you recommend then? I've seen the previous developer used the configuration manager to pass several settings, but i don't think that's a good idea either.
aggietech
What kind of settings?
Larsenal
actually, i just need to store the two values from the current sessions for error reporting. But my reporting method/class is in a different namespace than the web site.
aggietech
Are you talking about values you literally stored in `Session`?
Larsenal
yes somewhat, but needing to pass that to a server side utility class. I think i'm just going to move the singleton from the utility class to the web application project ... a little bit more work than i thought of.
aggietech
i used Session to store my per-session singleton class - thanks!
aggietech