简体   繁体   中英

access session value during concurrent requests

I have following problem.

in one request i am updating session variable. in the other request, i am trying to access that session value, but it was blocked until the first request finish.

I am using C# with ASP.NET 2.0

UPDATE :

My page code looks like this.

while(int progress = DoWork() && progress <= 100 ){
    Session["Progress"] = progress;
}

and my handler just return Session value.

context.Response.Write(Session["progress"].toString());
context.Response.End();

You really should not be running concurrent calls with ASP.net due to the nature of how the apps are developed. This sounds like a normal locking mechanism , the only thing you can really do is cater for a lock and just keep the thread waiting till the other thread is done.

If possible post some code as to what you are running multiple threads at the same time , there maybe a better way to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM