|
Subject:
|
question about profile and global.asax
|
|
Posted By:
|
hertendreef
|
Post Date:
|
1/24/2007 6:05:33 AM
|
Hi,
i'm trying to transform an anonymous user profile to an authenticated user profile, like chapter 13 of the book ASP.NET.
I found this global.asax here below and there are some things i don't understand. 1) where does the last function come from ( Public Sub Profile_OnMigrateAnonymous) because in VWDeveloper, that event doesn't appear in the available list of events? 2) when is it executed because it's not in the "Application_Start" (or _end) neither in "session_start"? On request? 3) in that function, there is a class defined 'ProfileCommon'. I discovered that that class was generated by a 'tool' and is not located in the application directory but in c:\windows\microsoft.net\v2..\Temporary Asp.net files\...\...\profile.cdcab7d2.vb . What tool is that and when was it generated? Why is not located in the application directory?
Thanks
<%@ Application Language="VB" %> <%@ Import Namespace="System.Web.Profile" %> <script runat="server"> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application startup End Sub Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application shutdown End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a session ends. End Sub
Public Sub Profile_OnMigrateAnonymous(ByVal Sender As Object, ByVal e As ProfileMigrateEventArgs) ' get the profile for the anonymous user Dim anonProfile As ProfileCommon = Profile.GetProfile(e.AnonymousID)
' if they have a shopping cart, then migrate that to the authenticated user If anonProfile.Cart IsNot Nothing Then
If Profile.Cart Is Nothing Then profile.Cart = New Test.Commerce.ShoppingCart() profile.Cart.Items.AddRange(anonProfile.Cart.Items) end if
anonProfile.Cart = Nothing End If
ProfileManager.DeleteProfile(e.AnonymousID) AnonymousIdentificationModule.ClearAnonymousIdentifier()
End Sub
</script>
'------------------------------------------------------------------------------ ' <auto-generated> ' This code was generated by a tool. ' Runtime Version:2.0.50727.42 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' </auto-generated> '------------------------------------------------------------------------------
Option Strict Off Option Explicit On
Imports System Imports System.Web Imports System.Web.Profile
Public Class ProfileCommon Inherits System.Web.Profile.ProfileBase
Public Overridable Property Country() As String Get Return CType(Me.GetPropertyValue("Country"),String) End Get Set Me.SetPropertyValue("Country", value) End Set End Property
Public Overridable Property City() As String Get Return CType(Me.GetPropertyValue("City"),String) End Get Set Me.SetPropertyValue("City", value) End Set End Property
Public Overridable Property Cart() As mai.eCommerce.ShoppingCart Get Return CType(Me.GetPropertyValue("Cart"),mai.eCommerce.ShoppingCart) End Get Set Me.SetPropertyValue("Cart", value) End Set End Property
Public Overridable Function GetProfile(ByVal username As String) As ProfileCommon Return CType(ProfileBase.Create(username),ProfileCommon) End Function End Class
|
|