Question Detecting whether anyone is logged in

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I am currently working on a Web Application that uses ASP.NET Membership. There are multiple places that I need to determine whether a user is logged in (Pages, Master Pages, UserControls, classes that I write, etc.). I have tried the following:

IsNothing(Membership.GetUser())
HttpContext.Current.Request.IsAuthenticated
User.Identity.IsAuthenticated

The thing that is frustrating me is figuring out when and where each of these will be available, and which one is best (or maybe there is another one that is better). Can somebody tell me which of these should be used where, or if there are any better ones? Thanks.
 
Top Bottom