Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 24th, 2007, 07:05 AM
Friend of Wrox
Join Date: Apr 2006
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default question about profile and global.asax


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?


<%@ 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

        AnonymousIdentificationModule.ClearAnonymousIdenti fier()

    End Sub


' <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
            Return CType(Me.GetPropertyValue("Country"),String)
        End Get
            Me.SetPropertyValue("Country", value)
        End Set
    End Property

      Public Overridable Property City() As String
            Return CType(Me.GetPropertyValue("City"),String)
        End Get
            Me.SetPropertyValue("City", value)
        End Set
    End Property

    Public Overridable Property Cart() As mai.eCommerce.ShoppingCart
CType(Me.GetPropertyValue("Cart"),mai.eCommerce.Sh oppingCart)
        End Get
            Me.SetPropertyValue("Cart", value)
        End Set
    End Property

    Public Overridable Function GetProfile(ByVal username As String) As
        Return CType(ProfileBase.Create(username),ProfileCommon)
    End Function
End Class

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
what is global.asax? gaurav_jain2403 General .NET 1 February 3rd, 2006 02:40 PM
global.asax ashokparchuri ADO.NET 1 February 25th, 2005 08:40 AM
An Error in Global.asax! Action BOOK: ASP.NET Website Programming Problem-Design-Solution 5 December 23rd, 2004 12:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.