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

  • Thread starter Thread starter Nightcrawler
  • Start date Start date
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
 
To me, I will normally use session state. That will be more independent for
whether the Membership is used.

Ming Man
 
Back
Top