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. Advertising

  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. Advertising

  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. Advertising

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:
    403
    Brent
    Dec 28, 2003
  2. 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,712
    Alan Silver
    May 26, 2005
  3. keithb
    Replies:
    0
    Views:
    632
    keithb
    Feb 16, 2006
  4. Rik Hemsley
    Replies:
    4
    Views:
    317
    Rik Hemsley
    Jul 4, 2006
  5. Replies:
    1
    Views:
    947
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
Loading...

Share This Page