ASP.NET 2.0 Membership Current User

R

Ray Booysen

Hi all

I'm wanting to know if its possible to retrieve the current user when
using the 2.0 membership provider. The GUID UserID in Users I am using
as a foreign key in other tables and I need to use it for other database
operations.

The membership class doesn't expose a CurrentUser() method and has Find
methods but not something I can use.

Any ideas?

Regards
Ray
 
G

Guest

Hello Ray,

The membership class exposes GetUser() not CurrentUser(). You should be able
to use the Membership.GetUser() method to get the current user:

MembershipUser u = Membership.GetUser(HttpContext.Current.User.Identity.Name);
if (u != null)
{
// do some work
}
 
R

Ray Booysen

brians said:
Hello Ray,

The membership class exposes GetUser() not CurrentUser(). You should be able
to use the Membership.GetUser() method to get the current user:

MembershipUser u = Membership.GetUser(HttpContext.Current.User.Identity.Name);
if (u != null)
{
// do some work
}
Great. Thanks for the help.

Regards
Ray
 

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