This property cannot be set for anonymous users - Problem assigning Profile properties when user should be authenticated. ASP.NET
Posted on 2010-09-09
I am trying to set a LastLoggedIn Profile Property at the point a user is authenticated via a Login Control. I am using the control's LoggedIn event to do this as below:
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
Profile.LastLoggedOn = DateTime.Now.ToString()
I had assumed that this event was raised once the user had been authenticated, but when I step into this User.Identity.IsAuthenticated is always False and so I get an error saying 'This property cannot be set for anonymous users'. If I remove this code however I am able to logon and pass authentication.
What am I doing wrong?