views:

1455

answers:

1

I keep track of the current logged in userID and base the behavior of my site on this value. My code sets the logged in user ID with this statement:

FormsAuthentication.SetAuthCookie(UserID.ToString(), true);

Subsequently, I read this value from Page.User.Identity.Name.

This works fine on my desktop, but on my server, I set it to 8 and it comes back 20. I am trying to figure out what can set Page.User.Identity.Name to a value and when this happens.

Thanks...

+1  A: 

FormsAuthenticationModule handles Application_OnAuthenticate and assigns the HttpContext.User to a prinicipal object which is in turn used by Page.User.Identity.Name.

Isn't there a time difference issue on the server and your desktop?

Mehrdad Afshari
That much I know. The problem is that Page.User.Identity.Name is changing its value within my code and I don't know why. At one point, it has the value 8 (correct), but when I load another page, the value has changed to 20. What can cause this to happen?
Bob Jones
How do you test it? Are you sure the page is not cached?
Mehrdad Afshari
I test with a series of trace statements in the code that show the current value of Page.User.Identity.Name. The trace statements come from various portions of the code. The values returned change depending on where in the code the trace statement is executing.
Bob Jones