Get anonymous profile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Get anonymous profile

    Hello,

    I am working with an ASP.NET MVC Web Application and I am using the
    following custom profile provider:



    One of the properties is allowed to anonymous users.

    How can I get the profile of an anonymous user? They don't have a
    username, right?

    I am a little bit lost on this.

    Thanks,

    Miguel
  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

    #2
    RE: Get anonymous profile

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

    -- bruce (sqlwork.com)


    "shapper" wrote:
    Hello,
    >
    I am working with an ASP.NET MVC Web Application and I am using the
    following custom profile provider:
    >

    >
    One of the properties is allowed to anonymous users.
    >
    How can I get the profile of an anonymous user? They don't have a
    username, right?
    >
    I am a little bit lost on this.
    >
    Thanks,
    >
    Miguel
    >

    Comment

    • shapper

      #3
      Re: Get anonymous profile

      On Nov 14, 4:45 pm, bruce barker
      <brucebar...@di scussions.micro soft.comwrote:
      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.G etProfile();

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

      public static ProfileHelper GetProfile() {
      return Create(System.W eb.Security.Mem bership.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.W eb.Security.Mem bership.GetUser ().UserName) as
      ProfileHelper;

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

      Thanks,
      Miguel



      Comment

      • shapper

        #4
        Re: Get anonymous profile

        On Nov 14, 5:59 pm, shapper <mdmo...@gmail. comwrote:
        On Nov 14, 4:45 pm, bruce barker
        >
        <brucebar...@di scussions.micro soft.comwrote:
        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.G etProfile();
        >
        Where ProfileHelper is my custom profile provider that inherits
        ProfileBase and has the following method:
        >
          public static ProfileHelper GetProfile() {
            return Create(System.W eb.Security.Mem bership.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.W eb.Security.Mem bership.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.W eb.Security.Mem bership.GetUser ().UserName)
        as ProfileHelper;
        } // GetProfile

        By:

        public static ProfileHelper GetProfile() {
        return Create(HttpCont ext.Profile.Use rName) as ProfileHelper;
        } // GetProfile

        Now I get the profile of the current user.

        Could someone give me a second opinion on my solution?

        Thanks,

        Miguel

        Comment

        Working...