Content getting swapped for multiple sessions users in asp.net website

3k Views Asked by At

I am developing an asp.net website.

  • When two different users are accessing that website with different sessions, one users content is getting swapped to another user.
  • I am using javacsript, calling pagemethods from .aspx pages and C# at code behind.
  • This problem mainly occuring when two users are calling same functionality at a time.
  • I thought static variables could cause this problem and tried not to use any static variables or static functions except for pagemethod functions where it is manadatory for a pagemethod to be static.

please help me out with this problem.

7

There are 7 best solutions below

0
On

We had a similar problem, and found that it was our loadbalancer(f5 Big-IP) that messed up the session-ids. We changed the loadbalancer to be stateful, and it now functions perfectly...

3
On

Could also be related to threading. Lock those variables up and see if that helps.

Static methods do not guarantee static variable state even though the methods are guaranteed to be thread-safe. You have to manage that state and asp.net treats static variables as shared amongst all users. See this answer from a related question.

More reading: Thread Synchronization

0
On

this is to be set in Web.config and <%@ outputcache duration="1" varybyparam="none" %> this to be removed all the .aspx Forms..

Regards Rs

0
On
  • turn on the aspnet state service in windows services.
  • use session["x"] instead of Static x
  • use viewstate["x"] for page level values
0
On

Add sessionState in web.config:

<configuration>
  <system.web>
   <sessionState timeout="120" mode=" [InProc|StateServer|SQLServer|Custom]" cookieless="false"  />
  </system.web>
</configuration>

Try also the following solution:

  1. Start>Administrative Tools>Services
  2. right click on ASP.NET State Service and click 'start'.

Variables also need to LOCK as mentioned in @TombMedia's Answer.

This link may be help you: Exploring Session in ASP.NET

0
On

Check your session state configuration (see example below). Perhaps you use another mode than "InProc" and running in some problems with that.

<sessionState mode="InProc" cookieless="false" timeout="60" />

You could also consider using caching instances with keys that using the SessionID as prefix. The enterprise library offers a good caching implementation.

Hope this helps.

0
On

remove you static variable and static method use to respond your request.