MemberShip, User, Roles.. is there a smarter way?

N

Nightcrawler

I am currently using the built in membership functionality with
asp.net 2.0. I currently have set the web.config to only store
registered users in the database. I don't want to polute the
aspnet_Users with anonymous users.

When a user gets to one of my aspx pages I would like to find out if
the user is logged in. I am currently doing it this way:

MembershipUser membershipUser = Membership.GetUser();

if (membershipUser != null)
{
... some code
}
else
{
... some code
}

Is there a better way? I feel that everytime I do this it will have to
pull the user from the database. It sounds like an expensive way to
see if the user is logged in or not.

Please let me know.

Thanks
 
C

Chan Ming Man

To me, I will normally use session state. That will be more independent for
whether the Membership is used.

Ming Man
 

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

Top