Is using asmx service to update a session variable via ajax call a problem when a lot of calls are made in succession?
I have a asmx (project is legacy ASP.NET with no WCF at the web application layer) webservice that updates a session variable. There is an ajax call that uses this method when a checkbox is clicked. It works unless you click the check boxes one after another (which could be done). The ajax call hangs (never finishes).
I'm thinking this has something to do with multiple requests trying to update the session variable, but I'm not sure. Anyone run into this an开发者_如何学Pythond could lend some advice? Note: I know WCF would be a possible answer, but I wondering if there is a solution that won't require changing the asmx service to WCF right now.
Is using asmx service to update a session variable via ajax call a problem when a lot of calls are made in succession?
Yes, as ASP.NET will queue and execute those requests sequentially and not in parallel because the session object is not thread safe. If multiple requests from the same session are sent to some ASP.NET handler and if this handler writes to the session it will simply queue those requests.
If your services is only updating the same key within the session variable you could always try to storing the value locally in a cookie until the value changes. Then when the value does change you could call your ASMX service to store the new value in your session variable.
Depending on the AJAX Library that you use, you always have the option to abandon the previous running call before firing the next call. If you can elaborate a bit more about how the web service is called I can possibly help you with the abandoning of previous calls before starting a new one.
精彩评论