Membership Class Annoyances or am I just ignorant?

D

David Lozzi

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
 
M

Mark Fitzpatrick

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

Brandon Gano

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?
 
K

Kevin Spencer

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
 
D

David Lozzi

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top