473,473 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Basic ASP.NET application scope question

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

Feb 9 '06 #1
6 1298
The use of Static (C#) or Shared (VB.NET) classes in ASP.NET can cause
issues similar to what you are describing. Take a look at the following KB
article:

http://support.microsoft.com/?id=893666

--

Andrew Robinson
http://blog.binaryocean.com

<pi*********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Feb 9 '06 #2
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
<pi*********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Feb 9 '06 #3
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.

Feb 9 '06 #4
You may be declaring your object with new but it can still contain static /
shared fields.

--

Andrew Robinson
http://blog.binaryocean.com
<pi*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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.

Feb 9 '06 #5
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.

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

Feb 9 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: steve | last post by:
I'm trying to create a structure of three pointers to doubles. For which I have: typedef struct { double *lst_t, *lst_vc, *lst_ic; } last_values; I then need to allocate space for...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
6
by: kathy | last post by:
I have a pointer: MyClass *p = NULL; p = new MyClass(...); .... delete p; After delete p, does p equal NULL(it is in C++ standard?)? How to decide if p has been deleted?
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
21
by: Roland | last post by:
The following issue is puzzling me: There are 2 ways of writing the code below: .... Dim fnt as Font = New Font(...) DrawString(myText, fnt,...) fnt.dispose(). or DrawString(myText, New...
21
by: Al Christoph | last post by:
I posted this last week end in the MSDN forums. No luck there. Let's see what the experts here have to say:-)))) I have a rather convoluted project. The distributable will come in eight...
7
by: garyusenet | last post by:
This is the first time i've worked with openfile dialog. I'm getting a couple of errors with my very basic code. Can someone point out the errors in what i've done please....
11
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
14
by: MartinRinehart | last post by:
Working on parser for my language, I see that all classes (Token, Production, Statement, ...) have one thing in common. They all maintain start and stop positions in the source text. So it seems...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.