Click here to Skip to main content
15,504,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
A booking software uses ASP.NET server-side and JS client-side. I'm exchanging data and validating fields via WebMethods which require to be static. The problem is, static variables are global and shared across the application and not the session and now it occures that data from multiple users are being mixed upon postback.

What I have tried:

I'm looking for an alternative that keeps the user sessions seperated from each other.
Posted
Updated 26-Aug-19 22:48pm
Comments
Richard MacCutchan 27-Aug-19 3:15am    
The answer is in the question: do not use static variables.

Instead of relying upon static variables, you can add these variables as parameters to the static method.
 
Share this answer
 
Comments
Patrick-Et. B. 27-Aug-19 9:54am    
Thank you, I have choosen your way. There was the problem of sending a huge amount of dynamically created field values across a PageMethod and I have to keep up an SqlConnection as well as another third party connection. But everything went fine.
phil.o 27-Aug-19 14:51pm    
You're welcome!
Webmethods are not intended for interacting with server-side controls as they are not part of the postback lifecycle. The simplest alternative would probably be to use an UpdatePanel. That lets you do ajax-style behaviours while retaining the ability to interact with server-side controls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900