Get anonymous profile

B

bruce barker

anonymous profiles are tied to a cookie rather than a login.

-- bruce (sqlwork.com)
 
S

shapper

anonymous profiles are tied to a cookie rather than a login.

-- bruce (sqlwork.com)

Yes, I know. And the cookie was added. I checked it with Firebug.

So how do I get the profile for an anonymous user?! I am using the
following:

ProfileHelper profile = ProfileHelper.GetProfile();

Where ProfileHelper is my custom profile provider that inherits
ProfileBase and has the following method:

public static ProfileHelper GetProfile() {
return Create(System.Web.Security.Membership.GetUser().UserName)
as ProfileHelper;
}

I always get the error "Object reference not set to an instance of an
object." on the following code line:
return Create(System.Web.Security.Membership.GetUser().UserName) as
ProfileHelper;

I don't understand how to solve this. any idea? Thanks ...

Thanks,
Miguel
 
S

shapper

Yes, I know. And the cookie was added. I checked it with Firebug.

So how do I get the profile for an anonymous user?! I am using the
following:

  ProfileHelper profile = ProfileHelper.GetProfile();

Where ProfileHelper is my custom profile provider that inherits
ProfileBase and has the following method:

  public static ProfileHelper GetProfile() {
    return Create(System.Web.Security.Membership.GetUser().UserName)
as ProfileHelper;
  }

I always get the error "Object reference not set to an instance of an
object." on the following code line:
return Create(System.Web.Security.Membership.GetUser().UserName) as
ProfileHelper;

I don't understand how to solve this. any idea? Thanks ...

Thanks,
Miguel

Hi,

I think I solved it. On my code I replaced:

public static ProfileHelper GetProfile() {
return Create(System.Web.Security.Membership.GetUser().UserName)
as ProfileHelper;
} // GetProfile

By:

public static ProfileHelper GetProfile() {
return Create(HttpContext.Profile.UserName) as ProfileHelper;
} // GetProfile

Now I get the profile of the current user.

Could someone give me a second opinion on my solution?

Thanks,

Miguel
 

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,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top