Hello,
Just wondering if someone could help me on a problem I have come accross. I am trying to have a 'last log-in date' display in my members area after a user signed in. I have researched to some solutions as to how to do this but haven't had much luck. I have given it ago but I keep getting the same error with all the tests I do. Below is the code I am using to store the date in the user profiles:
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
If Login1.UserName IsNot Nothing Then
Dim dtLastLogin As String = Today()
If Membership.ValidateUser(Login1.UserName, Login1.Password) Then
Profile.FirstName = "test"
Dim userInfo As MembershipUser = Membership.GetUser(Login1.UserName)
userInfo.LastLoginDate = dtLastLogin
e.Authenticated = True
End If
End If
End Sub-----------------------------------------------------------------------------------------------------
This code is called from a Login control like so:
<asp:Login ID="Login1" runat="server" VisibleWhenLoggedIn="False" OnAuthenticate="Login1_Authenticate" DestinationPageUrl="~/empServices.aspx">
Here is the error I am getting:
-----------------------------------------------------------------------------------------------------
This property cannot be set for anonymous users.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Configuration.Provider.ProviderException: This property cannot be set for anonymous users.
Source Error:
Line 58: }
Line 59: set {
Line 60: this.SetPropertyValue("FirstName", value);
Line 61: }
Line 62: }
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ewaassignment3\954aaa6a\cd248fcd\App_Code.-e1loqlf.0.cs Line: 60
-----------------------------------------------------------------------------------------------------
If anyone could give me any advice or point me in the right direction, that would be great. Thanks very much.
Edd 