Asp.net static object behaviour
Posted
by Circadian
on Stack Overflow
See other posts from Stack Overflow
or by Circadian
Published on 2010-05-04T11:05:30Z
Indexed on
2010/05/04
11:08 UTC
Read the original article
Hit count: 137
I have the following class as part of an asp.net application.
public sealed class SomeClass
{
private static string appId = Guid.NewGuid().ToString();
public static ReadSomethingFromDb(){}
public static WriteSomethingToDb(){}
}
There are more than one application instances in the same application pool, and they all access the same database. I want the operations performed by the above class to be uniquely tied to the instance that performed it, hence the use of the appId. So adding a record to the database would for example contain a name, address and appId. This has been simplified for discussion purposes.
Assuming that I have two instances running at mysite.a and mysite.b the above class would generate two different guids.
My problem is that mysite.a sometimes produces more than one guid, which is unexpected.
Thank you in advance
© Stack Overflow or respective owner