HttpContext.Current.User.Identity.Name loses value

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?
 
B

bruce barker

in asp.net, authentication is independent of session. if its not set,
then you page is not requiring authentication.

-- bruce (sqlwork.com)
 
D

Doogie

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.
 
J

Jim in Arizona

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.
 
D

Doogie

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top