Hi,
I'm starting my first asp.net application and I decided to put the
users preferences in a static class.
I thought, the static class would be just seen by current session, but
it seems it don't work like that (!?).
If I change some preference and I open a second browser session, even
another browser (netscape, opera), it seems the preferences are shared
like a big cookie among all browsers.
Thought, it is not perfectly consisten, sometimes, they do show the
same preference and some times they don't. Opera seems to be very
stubborn to read the preference when they were set through other
browser.
Well, the question is, what is the life of an static class in an
asp.net application ? is it session wide ? or it is instantiated once
for all users connected ? 9 1882
> Well, the question is, what is the life of an static class in an asp.net application ?
or it is instantiated once for all users connected ?
Yes.
For storing user preferences, you should use cookies or if your users have
to log in, you can write their preferences into a database. Then, at login,
you can restore their preferences. Cookies are the simplest solution but be
aware that some users may have cookies disabled and that cookie data isn't
secure.
<cr************@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Hi,
I'm starting my first asp.net application and I decided to put the users preferences in a static class. I thought, the static class would be just seen by current session, but it seems it don't work like that (!?).
If I change some preference and I open a second browser session, even another browser (netscape, opera), it seems the preferences are shared like a big cookie among all browsers. Thought, it is not perfectly consisten, sometimes, they do show the same preference and some times they don't. Opera seems to be very stubborn to read the preference when they were set through other browser.
Well, the question is, what is the life of an static class in an asp.net application ? is it session wide ? or it is instantiated once for all users connected ?
<cr************@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Well, the question is, what is the life of an static class in an asp.net application ? is it session wide ? or it is instantiated once for all users connected ?
What's the life of a static class in any application? Why would ASP.NET be
any different.
static (or Shared) members have one existence for all instances of a class
within an AppDomain. This is the opposite of an instance member, which has
one copy for each instance of a class.
This is exactly the case in ASP.NET.
If you want something which will be per-session, then you should use Session
state. If you want something which will be global to the entire application,
use Application state. Neither one is thread-safe, so be careful.
John Saunders
John :
Thanks for your answer. It is a bit more clear now.
Still I've not found an black&white response to following, not even in
the documentation :
what is the life of the asp.net dll ?
I don't think it is exactly like any other application :
I have a C# winform application, it has some static class. If I run my
application twice, I still having different copies of the static
classes in each of the executables.
However, here asp.net seems to share the dll data among the
connections, so, you know it is a little bit different concept,
specially when comming from win32 client applications. cr************@hotmail.com wrote: John :
Thanks for your answer. It is a bit more clear now. Still I've not found an black&white response to following, not even in the documentation : what is the life of the asp.net dll ? I don't think it is exactly like any other application : I have a C# winform application, it has some static class. If I run my application twice, I still having different copies of the static classes in each of the executables. However, here asp.net seems to share the dll data among the connections, so, you know it is a little bit different concept, specially when comming from win32 client applications.
If you start your winform app twice, you have two separate applications running.
An ASP.Net application is a *single* application running on a webserver,
serving *multiple* (possibly simultaneous) requests.
The application is started with the first request. I'm not sure exactly when
it finishes, it's either "never" or "after the last session has expired"
(which is default 20 minutes after the last request has been served).
Maybe someone else has a good answer here?
Hans Kesting
<cr************@hotmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com... John :
Thanks for your answer. It is a bit more clear now. Still I've not found an black&white response to following, not even in the documentation : what is the life of the asp.net dll ? I don't think it is exactly like any other application : I have a C# winform application, it has some static class. If I run my application twice, I still having different copies of the static classes in each of the executables.
If you run your windows application twice, you've got two separate
AppDomains, one in each process.
There is no ASP.NET equivalent to that. When a user accesses an ASP.NET web
site, ASP.NET doesn't start up a new process to run the web application, nor
does it start a new AppDomain (assuming that one is already running).
Multiple requests are serviced within the same AppDomain, therefore,
multiple requests will see the same copy of Shared data.
However, here asp.net seems to share the dll data among the connections, so, you know it is a little bit different concept, specially when comming from win32 client applications.
Very true.
I have wondered about the path that persons like yourself take in coming
from Win32 applications to ASP.NET. Not to sound too harsh, but how did you
NOT know that an ASP.NET application is so different from a Windows Forms
application? What documentation did you look at when getting started in
ASP.NET? Whichever documentation you used, it needs to have a big Stop sign
on the cover of it saying: READ THIS FIRST: WEB APPLICATIONS ARE DIFFERENT.
You are only the tenth person this month I've seen with this same problem,
and that's probably because I can't remember numbers 11 through 20! I'm not
picking on you, rather I'd like to find out what's causing this, perhaps in
time for Microsoft to add that Stop page before VS2005 ships.
In the meantime, here's where the Stop page should point to:
The ASP.NET Page Object Model
( http://msdn.microsoft.com/library/de...asp?frame=true)
Good Luck,
John Saunders
> You are only the tenth person this month I've seen with this same problem, and that's probably because I can't remember numbers 11 through 20! I'm not picking on you, rather I'd like to find out what's causing this, perhaps in time for Microsoft to add that Stop page before VS2005 ships.
It's probably because VS / .Net can handle both types of application,
so it's easy to try out the "other" one. I personally have a similar
problem in reverse: things that are easy in asp.net (screen generation mostly)
are very different in a winform application.
Hans Kesting
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:OR**************@TK2MSFTNGP15.phx.gbl... You are only the tenth person this month I've seen with this same problem, and that's probably because I can't remember numbers 11 through 20! I'm not picking on you, rather I'd like to find out what's causing this, perhaps in time for Microsoft to add that Stop page before VS2005 ships.
It's probably because VS / .Net can handle both types of application, so it's easy to try out the "other" one. I personally have a similar problem in reverse: things that are easy in asp.net (screen generation mostly) are very different in a winform application.
Oh, well, in this case documentation wouldn't have helped, because you
didn't read any before starting!
John Saunders
John Saunders wrote: "Hans Kesting" <ne***********@spamgourmet.com> wrote in message news:OR**************@TK2MSFTNGP15.phx.gbl... You are only the tenth person this month I've seen with this same problem, and that's probably because I can't remember numbers 11 through 20! I'm not picking on you, rather I'd like to find out what's causing this, perhaps in time for Microsoft to add that Stop page before VS2005 ships.
It's probably because VS / .Net can handle both types of application, so it's easy to try out the "other" one. I personally have a similar problem in reverse: things that are easy in asp.net (screen generation mostly) are very different in a winform application.
Oh, well, in this case documentation wouldn't have helped, because you didn't read any before starting!
John Saunders
Of course! I'm a developer, so I don't read documentation :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sahil Malik [MVP] |
last post by:
So here's a rather simple question.
Say in an ASP.NET application, I wish to share common constants as static
variables in global.asax (I know there's web.config bla bla .. but lets just
say I...
|
by: Vishwanathan Raman |
last post by:
Hi
I have a declared a static DataSet object SOBJ in Global.asax.I also have a
localy defined DataSet LSOBJ in Global.asax which I am storing in Application
State.Is there any technical...
|
by: Sahil Malik [MVP] |
last post by:
So here's a rather simple question.
Say in an ASP.NET application, I wish to share common constants as static
variables in global.asax (I know there's web.config bla bla .. but lets just
say I...
|
by: Marty |
last post by:
Hi,
I have a class that I modified to be static. It is now a public sealed
class and all function are static, no more constructor but a init()
function to do the constructor job.
This class...
|
by: JC |
last post by:
Suppose an ASP.Net project contains a public static class with public
methods and members that are used throughout the application. Of course
being static, there is only copy of the class within...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |