472,146 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Two Requests acessing the Session collection

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/
Nov 2 '06 #1
8 1900
Michael,

Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html

--
Regards

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

"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
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/


Nov 2 '06 #2
Hi John,
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:pc******************************@eclipse.net. uk...
Michael,

Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html

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

>
--
Regards

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

"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
>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/



Nov 2 '06 #3
It isn't something as simple as accessing HttpContext.Current.Session in
your ajax server method rather than just session is it and it not being on
context?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
Hi John,
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:pc******************************@eclipse.net. uk...
>Michael,

Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html


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

>>
--
Regards

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

"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
>>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/




Nov 2 '06 #4
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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:27******************************@eclipse.net. uk...
It isn't something as simple as accessing HttpContext.Current.Session in
your ajax server method rather than just session is it and it not being on
context?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
>Hi John,
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:pc******************************@eclipse.net .uk...
>>Michael,

Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html


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

>>>
--
Regards

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

"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
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/




Nov 2 '06 #5
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
"Michael Schwarz [MVP]" <no****@schwarz-interactive.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:27******************************@eclipse.net. uk...
>It isn't something as simple as accessing HttpContext.Current.Session in
your ajax server method rather than just session is it and it not being
on context?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
>>Hi John,
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:pc******************************@eclipse.ne t.uk...
Michael,

Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html
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

--
Regards

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

"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
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/
>
>




Nov 2 '06 #6
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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:Co********************@eclipse.net.uk...
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
"Michael Schwarz [MVP]" <no****@schwarz-interactive.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:27******************************@eclipse.net .uk...
>>It isn't something as simple as accessing HttpContext.Current.Session in
your ajax server method rather than just session is it and it not being
on context?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
Hi John,
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im
Newsbeitrag news:pc******************************@eclipse.net. uk...
Michael,
>
Take a quick look at this thread.
http://www.velocityreviews.com/forum...net-pages.html
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


>
--
Regards
>
John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
>
>
>
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl.. .
>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/
>>
>>
>
>




Nov 13 '06 #7
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
"Michael Schwarz [MVP]" <no****@schwarz-interactive.dewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:Co********************@eclipse.net.uk...
>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
"Michael Schwarz [MVP]" <no****@schwarz-interactive.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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/

"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im Newsbeitrag
news:27******************************@eclipse.ne t.uk...
It isn't something as simple as accessing HttpContext.Current.Session
in your ajax server method rather than just session is it and it not
being on context?

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
news:ee**************@TK2MSFTNGP04.phx.gbl...
Hi John,
>
>
"John Timney (MVP)" <x_****@timney.eclipse.co.ukschrieb im
Newsbeitrag news:pc******************************@eclipse.net. uk...
>Michael,
>>
>Take a quick look at this thread.
>http://www.velocityreviews.com/forum...net-pages.html
>
>
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
>
>
>
>
>>
>--
>Regards
>>
>John Timney (MVP)
>VISIT MY WEBSITE:
>http://www.johntimney.com
>http://www.johntimney.com/blog
>>
>>
>>
>"Michael Schwarz" <no****@schwarz-interactive.dewrote in message
>news:Om**************@TK2MSFTNGP04.phx.gbl. ..
>>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/
>>>
>>>
>>
>>
>
>




Nov 13 '06 #8
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

Nov 14 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Damien | last post: by
5 posts views Thread by PJ | last post: by
8 posts views Thread by Pietro | last post: by
reply views Thread by joseph conrad | last post: by
7 posts views Thread by =?Utf-8?B?Vkg=?= | last post: by
reply views Thread by leo001 | last post: by

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.