Membership Class Annoyances or am I just ignorant?

Discussion in 'ASP .Net' started by David Lozzi, Jul 23, 2007.

  1. David Lozzi

    David Lozzi Guest

    Howdy,

    My biggest annoyance with the membership class is that i cannot seem to get
    to it in my master files. I'd like to setup my master file to check for
    whether or not the current user is logged in or not, and if they are not,
    send them over to the login page. But I cannot access the membership class
    in a master page. I've done some reading up on this and some people have
    suggested using a session variable to store a flag to indicate whether or
    not the user is logged in. I tried that but it appears the membership class
    expires sooner than the session does. Any ideas?

    Thanks,

    David Lozzi
    David Lozzi, Jul 23, 2007
    #1
    1. Advertising

  2. Why not let the memberhsip system do this? If their cookie expires, then the
    membership system should automatically send them over to the login page you
    specify.

    The easiest way is just to test Page.User.Identity.IsAuthenticated to see if
    it's true.

    It sounds as if something isn't configured correctly as the system should be
    automatically handling all this for you. The entire point of the membership
    system is to not use session variables, those are old classic asp principals
    and aren't needed in ASP.Net 2.0.


    --
    Hope this helps,
    Mark Fitzpatrick
    Microsoft FrontPage MVP 199?-2006. 2007 and beyond

    "David Lozzi" <> wrote in message
    news:...
    > Howdy,
    >
    > My biggest annoyance with the membership class is that i cannot seem to
    > get to it in my master files. I'd like to setup my master file to check
    > for whether or not the current user is logged in or not, and if they are
    > not, send them over to the login page. But I cannot access the membership
    > class in a master page. I've done some reading up on this and some people
    > have suggested using a session variable to store a flag to indicate
    > whether or not the user is logged in. I tried that but it appears the
    > membership class expires sooner than the session does. Any ideas?
    >
    > Thanks,
    >
    > David Lozzi
    Mark Fitzpatrick, Jul 24, 2007
    #2
    1. Advertising

  3. David Lozzi

    Brandon Gano Guest

    All objects (Membership, Page, etc.) are re-created on every page
    load/postback. However, anything you save in the Session object will be
    re-created for each request.

    If you are saving the logged in status to the session correctly, you should
    be able to retrieve it later.

    That said, there is probably a better way to do what you are wanting. Have
    you looked into the built-in membership features as far as automatically
    re-directing unauthenticated users?


    "David Lozzi" <> wrote in message
    news:...
    > Howdy,
    >
    > My biggest annoyance with the membership class is that i cannot seem to
    > get to it in my master files. I'd like to setup my master file to check
    > for whether or not the current user is logged in or not, and if they are
    > not, send them over to the login page. But I cannot access the membership
    > class in a master page. I've done some reading up on this and some people
    > have suggested using a session variable to store a flag to indicate
    > whether or not the user is logged in. I tried that but it appears the
    > membership class expires sooner than the session does. Any ideas?
    >
    > Thanks,
    >
    > David Lozzi
    Brandon Gano, Jul 24, 2007
    #3
  4. The System.Web.Security.Membership class is a static class with static
    methods. In other words, you can get to it from any point in your code, as
    long as the namespace is resolved. However, when you say "I cannot access
    the membership class" you are not describing anything that helps diagnose
    what problem you're having. What exactly are you doing to "access" the
    class, and what is the result/behavior/exception that you are experiencing?

    --
    HTH,

    Kevin Spencer
    Microsoft MVP

    Printing Components, Email Components,
    FTP Client Classes, Enhanced Data Controls, much more.
    DSI PrintManager, Miradyne Component Libraries:
    http://www.miradyne.net

    "David Lozzi" <> wrote in message
    news:...
    > Howdy,
    >
    > My biggest annoyance with the membership class is that i cannot seem to
    > get to it in my master files. I'd like to setup my master file to check
    > for whether or not the current user is logged in or not, and if they are
    > not, send them over to the login page. But I cannot access the membership
    > class in a master page. I've done some reading up on this and some people
    > have suggested using a session variable to store a flag to indicate
    > whether or not the user is logged in. I tried that but it appears the
    > membership class expires sooner than the session does. Any ideas?
    >
    > Thanks,
    >
    > David Lozzi
    Kevin Spencer, Jul 24, 2007
    #4
  5. David Lozzi

    David Lozzi Guest

    I'm assuming the configuration is handled in the web.config file. Can you
    give me a sample of correctly configuring the membership class and I'm
    assuming the Forms authentication as well?

    Thanks,

    David Lozzi

    "Mark Fitzpatrick" <> wrote in message
    news:%...
    > Why not let the memberhsip system do this? If their cookie expires, then
    > the membership system should automatically send them over to the login
    > page you specify.
    >
    > The easiest way is just to test Page.User.Identity.IsAuthenticated to see
    > if it's true.
    >
    > It sounds as if something isn't configured correctly as the system should
    > be automatically handling all this for you. The entire point of the
    > membership system is to not use session variables, those are old classic
    > asp principals and aren't needed in ASP.Net 2.0.
    >
    >
    > --
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft FrontPage MVP 199?-2006. 2007 and beyond
    >
    > "David Lozzi" <> wrote in message
    > news:...
    >> Howdy,
    >>
    >> My biggest annoyance with the membership class is that i cannot seem to
    >> get to it in my master files. I'd like to setup my master file to check
    >> for whether or not the current user is logged in or not, and if they are
    >> not, send them over to the login page. But I cannot access the membership
    >> class in a master page. I've done some reading up on this and some people
    >> have suggested using a session variable to store a flag to indicate
    >> whether or not the user is logged in. I tried that but it appears the
    >> membership class expires sooner than the session does. Any ideas?
    >>
    >> Thanks,
    >>
    >> David Lozzi

    >
    >
    David Lozzi, Jul 26, 2007
    #5
    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. dan m

    painfully ignorant but frustrating

    dan m, Feb 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    296
    Alvin Bruney [MVP]
    Mar 2, 2004
  2. Mike
    Replies:
    4
    Views:
    355
  3. Rut

    xml ignorant

    Rut, Nov 19, 2004, in forum: XML
    Replies:
    3
    Views:
    419
    cr88192
    Nov 20, 2004
  4. ignorant question

    , Oct 2, 2004, in forum: Javascript
    Replies:
    8
    Views:
    87
  5. Debo
    Replies:
    8
    Views:
    109
Loading...

Share This Page