Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static fields on teh web

Status
Not open for further replies.

SharkTooth

Programmer
Aug 12, 2004
29
US
I was going to make a class that contained static methods that can be used in our apps including the web server. I have a concern though. My understanding is if i us a class that contains a static field and I change the value of the field then someone else accesses the class the filed will contain the new value.

On a web server:
If I have a Postoffice class that contains a SendMail method that uses a field "_mailServer" and I set the field equal to: "123.234.567" and another user showed up from a different desktop and does not change the "_mailServer" field it will remain the same value I set it to.

Is this right?
 
Only if they access it from within the same AppDomain. Your class could be running in many AppDomains if it is used in different applications and therefore have an independent value for each. That is why Session and Application variables should be used. Static variables for ASP.Net may only have meaning for multi-threading within a single interaction.

Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top