HttpContext.Current.User.Identity.Name loses value

  • Thread starter Thread starter Doogie
  • Start date Start date
D

Doogie

Hi,
I am using HttpContext.Current.User.Identity.Name to get a user id
from a web application. I then use that as part of a name of a cookie
I'm writing. 30 minutes later I do a refresh of this page and try to
access that cookie. However, because I am using
HttpContext.Current.User.Identity.Name to get the user id to know what
that cookie name even is, I am having problems because apparently
after 30 minutes HttpContext.Current.User.Identity.Name is no longer
returning a value. I think it has something to do with session
information only being available for 20 minutes by default.

Is there another way to get the user id other than
HttpContext.Current.User.Identity.Name?
 
in asp.net, authentication is independent of session. if its not set,
then you page is not requiring authentication.

-- bruce (sqlwork.com)
 
I'm not dealing with authentication. I'm trying to read the value in
that HttpContext.Current.User.Identity.Name value and it goes away
after 30 minutes. First time I go through it's there.
 
Doogie said:
Hi,
I am using HttpContext.Current.User.Identity.Name to get a user id
from a web application. I then use that as part of a name of a cookie
I'm writing. 30 minutes later I do a refresh of this page and try to
access that cookie. However, because I am using
HttpContext.Current.User.Identity.Name to get the user id to know what
that cookie name even is, I am having problems because apparently
after 30 minutes HttpContext.Current.User.Identity.Name is no longer
returning a value. I think it has something to do with session
information only being available for 20 minutes by default.

Is there another way to get the user id other than
HttpContext.Current.User.Identity.Name?

There's Request.ServerVirables("AUTH_USER") (or LOGON_USER i believe,
which gives same result if i remember correctly)
However, this property also comes out of httpcontext:

HttpContext.Current.ApplicationInstance.Request.ServerVirables("AUTH_USER")

I don't know if that will solve you problem or not.
 
Since it's part of HttpContext I'm guessing it'll be an issue as well,
but thank you. I did find out that if I do my refresh before the 20
minutes (say every 15), I don't lose that info in the HttpContext
object. It stays for quite some time (until my cookie expires and I
have to reget all my info then it goes away). Not sure why this is
but I think that's what I'll go with.
 
Back
Top