Excuse the extremely newbie question...
Once I 开发者_如何学运维have verified the users login credentials, Where should I store the state for whether a user is logged in or not?
Once you have validated that your user is OK according to the backend, you can make ASP.NET set an authentication cookie for the user in the response by doing a FormsAuthentication.SetAuthCookie(username, persistent)
.
From then on, ASP.NET will decrypt that cookie in requests and extract the username from it, giving you access to it via HttpContext.Current.User
.
To me, it sound like this is what you're looking for.
You don't normally need to store this state yourself. If you are using one of ASP.NET's built in authentication mechanisms (e.g. Form Auth) you can simply check: Request.IsAuthenticated
精彩评论