Basic ASP.NET application scope question

P

pinorama123

I have an ASP.NET application that contains a few classes that I have
built. One of my objects is a user object. I have a pretty basic
question about how this would work.

If I have multiple users logging into my application and using the user
object do they all share the same object or does ASP.NET know that each
user's object belongs to them? I'm seeing some strange behavior that
leads me to believe when one user dimensions an instance of the user
object that it is destroying the previous users instance.

Are classes in ASP.NET shared globally across the application? If so do
they need to be put into a session to be specific to the user? I think
I should avoid putting lots of things into the session.

I appreciate any help with this. I'm confused.

Thanks

Mike
 
S

S. Justin Gengo [MCP]

Mike,

It all depends on where the objects are being created and how they are
declared.

For example if you declare your class as shared or if you create the class
and store it in the application object then the object won't be threadsafe.

However if you declare a new instance of the object in the .aspx.vb page
code itself each page is a separate class and the object will be threadsafe.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
P

pinorama123

Thanks for the quick responses! I am declaring a new on each page in
the application. Does this ensure that the object instance only belongs
to that user? I am not putting anything into the application object. I
am getting some really strange behavior and trying to figure out how
users are seeing each others data.
 
A

Andrew Robinson

You may be declaring your object with new but it can still contain static /
shared fields.
 
P

pinorama123

What kind of fields would be considered static? The class has private
variables which are manipulated through properties. The object is built
from a function in a module in my web project. Could this possibly make
it global since I know a module and it's variables becomes shared in a
web application.
 
P

pinorama123

Thanks for all the help! It was a global variable being referenced that
was killing people's sessions.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top