Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have authentication code:
var authTicket = new FormsAuthenticationTicket(/*blahblah....*/);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(authTicket));
Response.Cookies.Add(cookie);
var name = HttpContext.User.Identity.Name; // line 4
By putting in debug statements, I find that name
on line 4 is empty. But the next time I make a call on this browser session, the HttpContext.User.Identity.Name
is correctly set.
So when does this value get set?
–
–
–
–
–
–
From your code it looks like you either would have to call:
FormsAuthentication.Authenticate(name, password)
or, if using Membership the following:
Membership.ValidateUser(name, password)
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.