By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

Static Class Factory - Alice is seeing Bob's data

P: n/a
Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.GetProfile(Guid
userID) which will take the user's GUID as an input and return me the Profile
memento class for use in interface. The memento class has no real
functionality, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types. Where I
would expect to see the first user's (Alice) image and data, I see Alice's
image with Bob's data in it. I know it isn't Bob's image because he has a
different type of image. The request to class factory with Alice's Guid has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?
Oct 11 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Static data are shared accross the whole application domain. As a web site
is a single application, it means that static data are shared accross all
users. This is mot often the problem (you still can use static properties as
long as the underlying storage is not shared).

--
Patrice

"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
a écrit dans le message de news:
2C**********************************@microsoft.com...
Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running
atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.GetProfile(Guid
userID) which will take the user's GUID as an input and return me the
Profile
memento class for use in interface. The memento class has no real
functionality, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types. Where
I
would expect to see the first user's (Alice) image and data, I see Alice's
image with Bob's data in it. I know it isn't Bob's image because he has
a
different type of image. The request to class factory with Alice's Guid
has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?

Oct 11 '07 #2

P: n/a
You may want to check http://support.microsoft.com/kb/893666/en-us for
details.

"Patrice" <http://www.chez.com/scribe/a écrit dans le message de news:
up**************@TK2MSFTNGP04.phx.gbl...
Static data are shared accross the whole application domain. As a web site
is a single application, it means that static data are shared accross all
users. This is mot often the problem (you still can use static properties
as long as the underlying storage is not shared).

--
Patrice

"ri***@newsgroups.nospam"
<ri*******************@discussions.microsoft.com a écrit dans le message
de news: 2C**********************************@microsoft.com...
>Morning,

I've got an ASP.NET 2.0 Web Application. Behind it, I've a
statically-scoped facade/class factory as the business layer, running
atomic
functions back and forth from my by DAL.

The DAL returns DataSet objects to the facade, which loads the data into
a
memento object to pass to the ASP.NET interface.

For instance, I've got the method Profile ProfileSystem.GetProfile(Guid
userID) which will take the user's GUID as an input and return me the
Profile
memento class for use in interface. The memento class has no real
functionality, it is just a representation of an object which can be used
safely either in my app or through a public web service.

I use these memento objects to create a PNG image. This is working very
well, and I've got four different designs.

However, occasionally, one user's image will contain a different user's
data. I can see that this isn't a image cacheing issue (as I thought at
first) because these two users will be using different image types.
Where I
would expect to see the first user's (Alice) image and data, I see
Alice's
image with Bob's data in it. I know it isn't Bob's image because he has
a
different type of image. The request to class factory with Alice's Guid
has
returned Bob's data (AFAICT).

Have I royally messed up my architecture here?


Oct 11 '07 #3

P: n/a
"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.com...
Have I royally messed up my architecture here?
Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #4

P: n/a
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.com...
Have I royally messed up my architecture here?

Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #5

P: n/a
you are confusing static methods with static objects. your factory
sample is a static method. this method is thread/session safe as long as
it and all of the method calls made do not use a static object. In your
case one of them must (there must be code that looks like you first
example).

-- bruce (sqlwork.com)
ri***@newsgroups.nospam wrote:
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
>"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
wrote in message news:2C**********************************@microsof t.com...
>>Have I royally messed up my architecture here?
Static variables in ASP.NET need *extremely* careful management because they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 11 '07 #6

P: n/a
This is not necessarily in this class. You'll have to check for input and
output values (if the argument or the result is at some point stored in a
static value it could cause the same problem). You could have also the same
problem somewhere in your "get data" code.

--
Patrice

"ri***@newsgroups.nospam" <ri*******************@discussions.microsoft.com >
a écrit dans le message de news:
B1**********************************@microsoft.com...
Thanks for the replys - I've read the article Patrice recommended.

I understand that using static objects can have issues with shared values
e.g.

static class TempStore
{

int myValue;

static TempStore()
{}

static Int GetValue()
{
return myValue;
}

static SetValue(int inpVal)
{
myValue = inpVal;
}
}
}

I can see that this would be bad as users will continuously be overwriting
each others values, but I don't see why this would be for a static class
factory

static class ClassFactory
{
static ClassFactory()
{}

static ProfileData GetProfile(Guid userID)
{
....Load DAL
....Get data
....Return data
}
}
Why would the GetProfile method above return the wrong data to the user?

Thanks
"Mark Rae [MVP]" wrote:
>"ri***@newsgroups.nospam"
<ri*******************@discussions.microsoft.co m>
wrote in message
news:2C**********************************@microso ft.com...
Have I royally messed up my architecture here?

Static variables in ASP.NET need *extremely* careful management because
they
persist across all Sessions. That's almost certainly what you're seeing
here...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Oct 11 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.