views:

20

answers:

1

I want to share data between two async requests to the server.

When some session variable value is changed in the first request (the value is changed continuously) I want the updated values in the second request.

How i should do this?

+1  A: 

If the requests are part of the same session, just use the session on the HttpContext. If not, then store the variable in the application context and update/use it from there.

tvanfosson
Tvanfosson if i store the value in session and initialize the session in the first request and then change it as value changes then the second request only gets the value of the session assigned first
munish
@munish - It could be that the second request is starting before the first request actually changes the value. Try putting the session access inside a critical section (using `lock` on a per-session lock object) so that you are sure that if the first request gets to the critical section first, the second won't get access until the first completes the update. Also, make sure they are using the same session. If not authenticated, you may need to set a cookie to keep the session sticky.
tvanfosson
Tvanfosson, My actual requirement is like thisIn mvc.net i am making first async request to server and it takes so much time thats why i want to add some progress bar on the page.For this i am making second asyn request to get the changed value so that i can change the value of progress bar.Thats why i have added session variable and changing the value time to time as save process proceeds. And i want to get this changed value using my second async request.
munish
@munish - is it possible that the browser (or server) is returning a cached result for the request? Try adding a timestamp parameter to the request so that it is different every time and make sure you have caching turned off on the server action.
tvanfosson