Asp.net session ends automatically after a few seconds

When the user logs in, I store the user_id in the Session variable, and on the second page check the page load, if the user_id exists then fine, otherwise redirects to the login page, but when I log in and redirect to the next page after a few seconds when I refresh the page my session is null and I am redirected to login to the page that it happens throughout the application. I tried all solutions but all in vain

Another thing is that the application works fine on the development server as well as on local IIS on the local network, but on the live server this problem occurs.

Please suggest a solution, I also define session time in minutes and mode in Proc in web.config.

Thank you in advance

+3


source to share


5 answers


You can add <httpRuntime delayNotificationTimeout=""/>

to your web.config. more details

OR



try it

<authentication mode="Forms">
  <forms loginUrl="/loginurl" timeout="2880" />
</authentication>

      

0


source


try this in web.config



<configuration>
 <system.web>
   <sessionState mode="InProc" timeout="90"></sessionState>
 </system.web>
</configuration>

      

0


source


One session issue I am having that might help here is that users from certain companies end the session quite quickly, but other users have no problem. After doing a lot of testing, I found that users connecting to the website from their office experience problems, but the same user connecting from home has no problems.

Their company is configured to use a single IP address (or set of IP addresses) for all associated web requests. Well, this company had multiple IPs to access the site, and that IP changed (or may change) with every request. This will reset the session on my website and log out.

I'm still in the process of implementing a fix or validation for this, so I can't give you a flawless proof, but it's something to look into. This explains what is happening to you.

0


source


Is there a chance you are using a server cluster? Network Load Balancing can redirect the client to a different server each time. If so, either NLB must be reconfigured to keep the client on the same server or to set up a session.

Also check that there is no obscene rule in the application pool to recycle too often.

0


source


If you are using InProc session state mode and multiple worker processes in the application pool, the session may expire automatically after a few seconds, as data loss can occur if different worker processes are served by different requests.

In my case, I am using InProc session state mode with max workflow set to 4 , hence the session will expire .

Setting Max Workflow = 1 solved this .

0


source







All Articles