Static Class VS. Application State

S

Smithers

I have a few variables that need to be accessible throughout my ASP.NET Web
app, across all possible Sessions.

AFAIK, there are two reasonable places to store them:
1. Application state (read the values from Web.config on ApplicationStart()
and then refer to them there).

2. properties of a static class (read values from Web.config when the app
starts, and then refer to them there).

Are there any good reasons to chose one of these approaches over the other?
I have currently implemented via #2, but was just wondering if anyone sees
any problems with that approach.

Thanks!
 
S

Steve C. Orr [MVP, MCSD]

#1 is the standard way to do this kind of thing.

#2 isn't necesarrily bad, but you can encounter rare, hard to debug
threading problems if you're not careful about how you implement this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top