Most Efficient Way to Tell if User is Logged On

Discussion in 'ASP .Net' started by Jonathan Wood, Oct 27, 2009.

  1. My code needs to test if the user is currently logged on.

    I know I can check if Membership.GetUser() returns null, but that returns
    data from the database that I don't need. I'm thinking there should be some
    sort of flag that doesn't require a database hit (or at least not one in
    addition to whatever ASP.NET is doing).

    Any tips?

    Thanks.

    Jonathan
     
    Jonathan Wood, Oct 27, 2009
    #1
    1. Advertisements

  2. On Oct 27, 8:06 pm, "Jonathan Wood" <> wrote:
    > My code needs to test if the user is currently logged on.
    >
    > I know I can check if Membership.GetUser() returns null, but that returns
    > data from the database that I don't need. I'm thinking there should be some
    > sort of flag that doesn't require a database hit (or at least not one in
    > addition to whatever ASP.NET is doing).
    >
    > Any tips?
    >
    > Thanks.
    >
    > Jonathan


    HttpContext.User.Identity.IsAuthenticated
     
    Alexey Smirnov, Oct 27, 2009
    #2
    1. Advertisements

  3. Looks like just what I needed, buried somewhat deeply.

    Thanks!

    "Alexey Smirnov" <> wrote in message
    news:...
    > On Oct 27, 8:06 pm, "Jonathan Wood" <> wrote:
    >> My code needs to test if the user is currently logged on.
    >>
    >> I know I can check if Membership.GetUser() returns null, but that returns
    >> data from the database that I don't need. I'm thinking there should be
    >> some
    >> sort of flag that doesn't require a database hit (or at least not one in
    >> addition to whatever ASP.NET is doing).
    >>
    >> Any tips?
    >>
    >> Thanks.
    >>
    >> Jonathan

    >
    > HttpContext.User.Identity.IsAuthenticated



    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
     
    Jonathan Wood, Oct 27, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brent Minder
    Replies:
    3
    Views:
    586
    Brent
    Dec 28, 2003
  2. Peter
    Replies:
    1
    Views:
    468
    Steve C. Orr [MVP, MCSD]
    Nov 9, 2004
  3. Alan Silver

    How do I tell if the user if logged in?

    Alan Silver, May 25, 2005, in forum: ASP .Net
    Replies:
    11
    Views:
    4,891
    Alan Silver
    May 26, 2005
  4. keithb
    Replies:
    0
    Views:
    778
    keithb
    Feb 16, 2006
  5. Linus Nikander
    Replies:
    5
    Views:
    782
  6. Razvan
    Replies:
    11
    Views:
    678
    Dale King
    Oct 12, 2004
  7. davout
    Replies:
    0
    Views:
    464
    davout
    Oct 28, 2004
  8. Rik Hemsley
    Replies:
    4
    Views:
    491
    Rik Hemsley
    Jul 4, 2006
Loading...