473,511 Members | 15,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Losing Session state

Hello all, I have some issue which is driving me crazy in testing my site...

Every now and then, the session variables in my site all get cleared out. I
assume this is because of something causing the AppPool to recycle.
The thing that really throws a wrench into all this though, is that after
the app recycles, User.Identity.IsAuthenticated is still returning true!
So despite the fact that the session and all its information is gone, and
effectively destroyed, the app is still reporting that the user is logged
in.
How can I either get it to stop recycling, or to sign the user out along
with the recycle?????

Thanks in advance,
- Arthur Dent.

Jun 27 '08 #1
4 1588
Hi,

if your application uses InProc session state, that indeed is wiped out when
application pool recycled. And especually in ASP.NET 2.0 or better apppool /
application restarts can occur quite easily (a few changes to files, change
in web.config, adding new dlls to bin etc etc). Therefore it's best to use
out-of-process session state modes such as SQL Server or State Server

http://msdn.microsoft.com/en-us/library/ms178586.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:2D**********************************@microsof t.com...
Hello all, I have some issue which is driving me crazy in testing my
site...

Every now and then, the session variables in my site all get cleared out.
I assume this is because of something causing the AppPool to recycle.
The thing that really throws a wrench into all this though, is that after
the app recycles, User.Identity.IsAuthenticated is still returning true!
So despite the fact that the session and all its information is gone, and
effectively destroyed, the app is still reporting that the user is logged
in.
How can I either get it to stop recycling, or to sign the user out along
with the recycle?????

Thanks in advance,
- Arthur Dent.

Jun 27 '08 #2
Depending on what type of authentication your site uses (Forms auth, for
example), this does not depend on Session State at all. Forms auth has a
forms ticket in the form of a cookie that is read by the forms
authentication provider on each page request. If the cookie is there, you
are authenticated. Nothing to do with Session at all.
Peter

"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:2D**********************************@microsof t.com...
Hello all, I have some issue which is driving me crazy in testing my
site...

Every now and then, the session variables in my site all get cleared out.
I assume this is because of something causing the AppPool to recycle.
The thing that really throws a wrench into all this though, is that after
the app recycles, User.Identity.IsAuthenticated is still returning true!
So despite the fact that the session and all its information is gone, and
effectively destroyed, the app is still reporting that the user is logged
in.
How can I either get it to stop recycling, or to sign the user out along
with the recycle?????

Thanks in advance,
- Arthur Dent.
Jun 27 '08 #3

"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:2D**********************************@microsof t.com...
>
.. or to sign the user out along with the recycle?????

You might find this article helpful :

http://www.abstraction.net/content/a...%20asp.net.htm

So, in the Session_Start event, once a new session is detected, you could
call :

FormsAuthentication.SignOut( ); to logout, if you are using forms
authentication.

Also note that the code shown in the Session_Start event has a potential
problem - if a user was on the Login page when session expired, it will
redirect back to the Login page, which is not necessary. So you could check
the page of the current request, and not perform the redirect if you are
already on the login page.

HTH,
Moe


Jun 27 '08 #4
This seems like the best approach. I'm kind of working this direction now,
but your post helped clarify and clean up the logic I was using.
The article also is a very good discussion.

Thanks for the help!! CheerZ

"Moe Sisko" <nullwrote in message
news:#o**************@TK2MSFTNGP04.phx.gbl...
>
"Arthur Dent" <hi*********************@yahoo.comwrote in message
news:2D**********************************@microsof t.com...
>>
.. or to sign the user out along with the recycle?????


You might find this article helpful :

http://www.abstraction.net/content/a...%20asp.net.htm

So, in the Session_Start event, once a new session is detected, you could
call :

FormsAuthentication.SignOut( ); to logout, if you are using forms
authentication.

Also note that the code shown in the Session_Start event has a potential
problem - if a user was on the Login page when session expired, it will
redirect back to the Login page, which is not necessary. So you could
check the page of the current request, and not perform the redirect if you
are already on the login page.

HTH,
Moe

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1633
by: Nikander Bruggeman | last post by:
Hi, In a situation where I have 2 servers which are load balanced I keep losing session state, although I store the session state in sql server and use a cookieless session, so that the session...
4
2390
by: Keith-Earl | last post by:
I have been writing ASP.NET apps since the RTM build and have never seen this. I built a simple app that uses session variables on my DEV laptop. All runs well. I have a simple toggle routine...
3
2099
by: Vinay Joseph Mathew | last post by:
Hi, I am having a problem with the Session State. I am running IIS 5 on Win2K. We are using 4 webservers with a load balancer. One of the webservers also acts as a State Server. Here is the...
5
5258
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the...
2
3434
by: Jayhawktuba | last post by:
I work as a IIS Admin for a company and we have migrated some ASP.NET apps from IIS 5 to IIS 6. They worked fine under IIS 5. They had their session state set to time out after 120 minutes and they...
9
2533
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
0
1670
by: none | last post by:
Hi, I've got a problem with losing session state in ASP.NET version 2. It does it intermittently - sometimes it tanks - and sometimes it works OK. I've got the ASP.NET state service started...
1
2845
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I have an application in which I store state in the Session object. There are two paths of execution in the Page_Load method of the default page. In one path the Session state is preserved across...
1
2899
by: Andy | last post by:
Hi Gang I need help. I have an ASP application that in a nutshell allows data entry on a main page. The problem is I'll have users that enter some data and save it. Then they'll enter some...
0
7252
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.