This property can not be set for anonymous users
Guys,
I am getting this error once in a while : System.Configuration.Provider.ProviderException: This property cannot be set for anonymous users.
any help is appreciated
when user tries to log in, once user name and password is authenticated in database, I execute following code to set the profile
FormsAuthentication.SetAuthCookie(userName, false);
System.Security.Principal.GenericIdentity identity = new System.Security.Principal.GenericIdentity(userName );
System.Security.Principal.GenericPrincipal user = new System.Security.Principal.GenericPrincipal(identit y, null);
Context.User = user;
SqlDataReader dr = myDB.GetUserInformation(userName);
if (dr.Read())
{
Profile.FirstName = dr["FirstName"].ToString();
Profile.LastName = dr["LastName"].ToString();
}
dr.Close();
|