In ASP.Net, I am trying to get the UserId (i.e., the user GUID) of the user that just logged on, in the LoggedIn event of the Login control. That is, I want to grab the UserId before the user is moved to to the next page. This is the code I am using:
Protected Sub Login1_LoggedIn(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Login1.LoggedIn
Dim UserId As String
UserId = Membership.GetUser.ProviderUserKey.ToString()
End Sub
However, I get an "Object reference not set to an instance of an object" error. This same code works well when I use it in subsequent pages, when a logged in user is accessing these pages.