Get anonymous profile

  • Thread starter Thread starter shapper
  • Start date Start date
anonymous profiles are tied to a cookie rather than a login.

-- bruce (sqlwork.com)
 
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
 
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
 
Back
Top