I'm building a complex web-based reservations system.
Gathering the user's data requires between 8 and 15 pages (depending on
which options they are interested in). I use the "Session" object to store
the various elements as the user moves through the pages.
Rather than storing the preferences directly in the Session object (e.g.
Session("LastName") = ...), I created a class
<Serializable()> Public Class ReservationInfo
This class has private variables for all the data, and exposes properties to
retrieve/manipulate the data. I did this for several reasons:
* I don't have to worry about screwing up variable names from one page
to the next (is it Session("OptionNumber") or is it Session("OptionNbr")) --
* I can add some logic related to the assignment of properties (e.g. if
a property changes, I might need to reset other properties)
In one of my modules I declare
dim g_Info as ReservationInfo
And on each page, then, in the OnLoad event, I have something to this
effect:
g_Info = Current.Session("ReservationInfo")
(actually, in the OnLoad event I call a public sub in one of my
modules, and it does the retrieval. That's why it references
Current.Session)
and in the Unload event, I have
Session("ReservationInfo") = g_Info
This way my entire set of variables is loaded from the Session, and saved
back to the session each time.
I let .NET manage the Session object in memory (single server), and
everything works great (or at least it did during my development/testing).
The problem happened when we ran the first multi-user test (e.g. 5 people
testing at the same time).
Suddenly, as users moved from page to page, their session information was
getting swapped with the information from another user. Every so often
(every couple of pages or so), as you moved from one page to another, you
suddenly wound up with the data of another user on the system.
I then added logic so that in the unload event, it would serialize and dump
the entire g_Info object to disk, and the filename would be based on the
SessionID of the user. That way I could trace the session information of
each user as they moved from page to page. I've confirmed that this happens
there. It seems that when it retrieves the data from the Session object
g_Info = Current.Session("ReservationInfo")
it sometimes grabs the wrong data.
I've analyzed several hundred page requests, and found many occurrences, but
can't find any pattern to it.
I don't have a clue how this could be. Any ideas? 2 2363
Hello Boban, there. It seems that when it retrieves the data from the Session object g_Info = Current.Session("ReservationInfo") it sometimes grabs the wrong data. I've analyzed several hundred page requests, and found many occurrences, but can't find any pattern to it.
Could this be because of the global g_Info variable?
For what its worth, I implement a similar pattern when doing session state, however, I expose my object using a singleton pattern.
Code Example:
class SessionManager
{
private const string SESSION_MANAGER = "SESSION_MANAGER";
private string username;
private SessionManager()
{
}
public string UserName
{
get { return username; }
set { username = value; }
}
public static SessionManager Instance
{
SessionManager manager = HttpContext.Current.Session[SESSION_MANAGER] as SessionManager;
if (manager == null)
{
manager = new SessionManager();
HttpContext.Current.Session[SESSION_MANAGER] = manager;
}
return manager;
}
}
When I want to access the session state in the code, I type
SessionManager.Instance.UserName = "someValue"; or
string someValue = SessionManager.Instance.UserName;
The idea is quite similiar to yours, and this should resolve your problems.
--
Matt Berther http://www.mattberther.com
A module is a class with shared variables (possibly as private members). As
such all users are sharing the same g_Info.
"Boban Dragojlovic" <news@_N_O_S_P_AM_dragojlovic.org> a écrit dans le
message de news:u6******************@newssvr27.news.prodigy.c om... I'm building a complex web-based reservations system.
Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to
store the various elements as the user moves through the pages.
Rather than storing the preferences directly in the Session object (e.g. Session("LastName") = ...), I created a class
<Serializable()> Public Class ReservationInfo
This class has private variables for all the data, and exposes properties
to retrieve/manipulate the data. I did this for several reasons: * I don't have to worry about screwing up variable names from one page to the next (is it Session("OptionNumber") or is it
Session("OptionNbr")) -- * I can add some logic related to the assignment of properties (e.g.
if a property changes, I might need to reset other properties)
In one of my modules I declare
dim g_Info as ReservationInfo
And on each page, then, in the OnLoad event, I have something to this effect: g_Info = Current.Session("ReservationInfo")
(actually, in the OnLoad event I call a public sub in one of my modules, and it does the retrieval. That's why it references Current.Session)
and in the Unload event, I have Session("ReservationInfo") = g_Info
This way my entire set of variables is loaded from the Session, and saved back to the session each time.
I let .NET manage the Session object in memory (single server), and everything works great (or at least it did during my development/testing). The problem happened when we ran the first multi-user test (e.g. 5 people testing at the same time). Suddenly, as users moved from page to page, their session information was getting swapped with the information from another user. Every so often (every couple of pages or so), as you moved from one page to another, you suddenly wound up with the data of another user on the system.
I then added logic so that in the unload event, it would serialize and
dump the entire g_Info object to disk, and the filename would be based on the SessionID of the user. That way I could trace the session information of each user as they moved from page to page. I've confirmed that this
happens there. It seems that when it retrieves the data from the Session object g_Info = Current.Session("ReservationInfo") it sometimes grabs the wrong data.
I've analyzed several hundred page requests, and found many occurrences,
but can't find any pattern to it.
I don't have a clue how this could be. Any ideas?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bobby |
last post by:
Hello everyone I have a question. The school I am working for is in
the beginning process of having a webpage that will direct students to
download there homework and be able to view there info...
|
by: Elliot M. Rodriguez |
last post by:
I am having a heckuva time debugging this, or determining why my page is
behaving this way.
I have a search form, that when completed, returns a datagrid. When the user
selects a row (normal...
|
by: Boban Dragojlovic |
last post by:
I'm building a complex web-based reservations system.
Gathering the user's data requires between 8 and 15 pages (depending on
which options they are interested in). I use the "Session" object to...
|
by: Steve Peterson |
last post by:
Hi
I have an application that is designed for multi clients, therefore users
must go through a login page. Upon logging in I set some properties in a
class, one of which is the user id (integer)...
|
by: David Young |
last post by:
I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.
We've apparently got an object (custom...
|
by: Aaron |
last post by:
Why do my session values return to nothing on post back?
I want to click a button and have the row, as in: dataset.table(0).rows(THIS
ROW NUMBER IS WHAT I AM TALKING ABOUT), either increment or...
|
by: pamelafluente |
last post by:
I am still working with no success on that client/server
problem. I need your help. I will submit simplified versions
of my problem so we can see clearly what is going on.
My model:
A client...
|
by: Gurunadh |
last post by:
Hi
i've some web user controls in one folder and web pages in some other
folder.
and i've included header web user control in all my web pages.
and in that user control wrote code to get the...
|
by: bmallett |
last post by:
I am getting the following error:
Error Type:
ADODB.Command (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another....
|
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: 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: 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,...
|
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: 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...
|
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...
|
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...
| |