Two Requests acessing the Session collection

  • Thread starter Michael Schwarz
  • Start date
M

Michael Schwarz

Hi,

I have a problem where I have two requests (i.e. two different windows that
are using the same session) that are accessing the session collection. The
requests will need more time on the server, but I get the problem that the
two sessions are not getting updated values from each requests. Is this by
design or is there any solution to do this?

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/
 
M

Michael Schwarz

Hi John,


John Timney (MVP) said:


hm, but if I have two requests with the same SessionID (Ajax requests) and
with this I cannot sync both sessions.

Example: first request will run for 10 seconds, and the second one will get
the progress. I get it working using SQL Server or static variables (app
wide), but not with the session collection. :(

Michael
 
M

Michael Schwarz [MVP]

The problem is that one requests changed a session variable that will not be
visible to the other request. Is the session collection only be updated when
request is finished?


--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/
 
J

John Timney \(MVP\)

The session data is not stored until ReleaseRequestState is called - at the
end of the request. Your Ajax method should not use session if you want
dynamic session data across calls from the same sesion client as marking the
method with SessionStateRequirement.ReadWrite will block the session access
until the first request completes. Given what your trying to do, your
perhaps better off not using session.

Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
 
M

Michael Schwarz [MVP]

That means that it is not possible to use Session state information in two
concurrent requests until ReleaseRequestState is called. What do you
recommend to use to communicate between two concurrent calls? Application is
not the correct context.

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/
 
J

John Timney \(MVP\)

I'm not sure Micheal, it seems your problem is only connected to having two
requests trying to access the same session data asynch - not that you can't
access the session data at all? Is that correct?

I've not actually come across the problem but i it was me, I'd stick the
values in the database or investigate the cache object perhaps.

You could always try calling ReleaseRequestState from your second call to
force termination of the session lock and update session - not sure if it
would work though, or what any side effects might be throuigh Ajax.

Why dont you ask Scott Guthrie for a recomendation - you would guess he must
have come across this already?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
 
H

heinz

You can maybe override ReleaseRequestState and associated methods
with your own version.
Say, try using thread wait, notify with delegate callbacks to update
your concurrent requirements.
Would be interesting and possibly useful piece of code for all
of us.

also when the ReleaseRequestState event is raised, the application is
finished with the request and ASP.NET is signaled to store the request
state.

wawens
 

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,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top