How to call a system event from a page

Last post 11-07-2009 1:59 PM by duckkiller53. 2 replies.

Sort Posts:

  • How to call a system event from a page

    11-07-2009, 8:30 AM

     Could someone Please help. I am learning Personalizaion and in particular "Working with Anonymous Identification"I have read that you can create your own unique AnonymousID ( vs a GUID ) by using the event AnonymousIdentification_Creating in a Glabal.asax file or at the page level.  I was able to get this to fire from my Global.asax file by simply placing the following code in the file.  But how do you call this from the page level.  I've tried just calling the sub routine but Visual Studio doesn't like that.

    Public Sub AnonymousIdentification_Creating(ByVal sender As Object, ByVal e As AnonymousIDentificationEventArgs)


    e.AnonymousID = "TestID " & DateTime.Now()



    Thanks


    Dave.

     

    Duckkiller53

    Duckkiller53@gmail.com
  • Re: How to call a system event from a page

    11-07-2009, 11:03 AM
    • Contributor
      4,149 point Contributor
    • fayaz_3e
    • Member since 09-14-2007, 10:15 AM
    • Hyderabad
    • Posts 868

    Hi,

    I am not sure of Anonymous Identification Module. But your question is how to raise galobal.asax event from page level. Dear, global events will be raised automatically. You need not invoke them explicitely. And reg AnonymousIdentification_Creating, that will be raised during the PostAuthenticateRequest event. Refer msdn for more info

    http://msdn.microsoft.com/en-us/library/system.web.security.anonymousidentificationeventhandler.aspx

    Fayaz
  • Re: How to call a system event from a page

    11-07-2009, 1:59 PM

    Fayaz:


         Thanks for the response.  If I sound really lost with this stuff I am please bare with me.  This is what the author of the book I'm reading states about working with Anonymous Identification.  I was able to get the AnonymousIdentification_Creating to fire by simply placing it in the Global.asax file. It worked and the AnonymousID changed.  Is that because the sub in Listing 15-15 is actually a delegate to an event?  Also, the next section talks about the Profile_MigrateAnonymous() event and that it can be placed in the page that deals with the migration.  How do you do get it to fire.  Everything that I have read on events states that you delcare and event, you raise the event, and then you set a sub to be called when the event fires using the 'Handles' clause.  Or you can create a Delegate and point that delegate to a method of a method with a similar signature.  But the below explanation does not follow any of those rules.   Any help would be greatly appreaciated.



    In working with the creation of anonymous users, be aware of an important event which you can use from your Global.asax file that can be used for managing the process:  AnonymousIdentification_Creating

    By using the AnonymousIdentification_Creating event, you can work with the identification of the end
    user as it occurs. For instance, if you do not want to use GUIDs for uniquely identifying the end user, you can change the identifying value from this event instead.
    To do so, create the event using the event delegate of type AnonymousIdentificationEventArgs, as illustrated in Listing 15-15.


    Listing 15-15:

    Public Sub AnonymousIdentification_Creating(ByVal sender As Object, ByVal e As AnonymousIDentificationEventArgs)
            e.AnonymousID = "Anonymous test " & DateTime.Now()
    End Sub


    The Author Also states this about migrating Anonymous users using Profile_MigrateAnonymous event handler.



    When working with anonymous users, you must be able to migrate anonymous users to registered users. for example, after an end user fills a shopping cart, he can register on the site to purchase the items.  At that moment, the end users switches from being an anonymous user to a registered user.  For this reason, ASP.NET provides a Profile_MigrateAnonymoous event handler enabling you to migrate anonymous users to registered users.  The profile_MigrateAnonymouseevent requires a data class of type ProfileMigrateEventArgs.  It is placed either in the page that deals with the migration or within the Global.asax file (if it can be used from anywhere within the application).  The use of this event is illustrated in Listing 15-17

    Listing 15-17

    Public Sub Profile_MigrateAnonymous(ByVal sender As Object, ByVal e As ProfileMigrateEventArgs)


         Dim anonymousProfile As ProfileCommon = Profile.GetProfile(e.AnonymousID)
         Profile.LastVisited = anonymousProfile.LastVisited


    End Sub


    Duckkiller53

    Duckkiller53@gmail.com
Page 1 of 1 (3 items)