Asp.net static object behaviour
- by Circadian
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