Using profile as custom class (getting null while taking data from profile _
-
How can i use custom class a profile i have class namespace MyCompany.CodeBlog{ [Serializable] public class UserProfile { private string userid; private string ipAddres; private string name; public static UserProfile GetUserProfile(string username) { return Create(username) as UserProfile; } public static UserProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as UserProfile; } [SettingsAllowAnonymous(false)] public string UserId { get { return userid; } set { userid = value; } } [SettingsAllowAnonymous(false)] public string IpAddress { get { return ipAddres; } set { ipAddres = value; } } [SettingsAllowAnonymous(false)] public string Name { get { return name; } set { name = value; } } } } And i want to use this a profile in my web config file i have < profile enabled="true"> < properties> < add name="UserProfile" type="MyCompany.CodeBlog.UserProfile" /> < / properties > < / profile > in my login page after validating the user i used Profile.UserProfile.UserId = "1"; Profile.UserProfile.Name = "myname"; Profile.UserProfile.IpAddress = "myip"; but in another page if (Request.IsAuthenticated) { //Error here string mystr = Profile.UserProfile.Name; //mystr is null } So please guide me if i am completely wrong or i have missed some thing i dont want tto use propfile property in webconfg file
-
How can i use custom class a profile i have class namespace MyCompany.CodeBlog{ [Serializable] public class UserProfile { private string userid; private string ipAddres; private string name; public static UserProfile GetUserProfile(string username) { return Create(username) as UserProfile; } public static UserProfile GetUserProfile() { return Create(Membership.GetUser().UserName) as UserProfile; } [SettingsAllowAnonymous(false)] public string UserId { get { return userid; } set { userid = value; } } [SettingsAllowAnonymous(false)] public string IpAddress { get { return ipAddres; } set { ipAddres = value; } } [SettingsAllowAnonymous(false)] public string Name { get { return name; } set { name = value; } } } } And i want to use this a profile in my web config file i have < profile enabled="true"> < properties> < add name="UserProfile" type="MyCompany.CodeBlog.UserProfile" /> < / properties > < / profile > in my login page after validating the user i used Profile.UserProfile.UserId = "1"; Profile.UserProfile.Name = "myname"; Profile.UserProfile.IpAddress = "myip"; but in another page if (Request.IsAuthenticated) { //Error here string mystr = Profile.UserProfile.Name; //mystr is null } So please guide me if i am completely wrong or i have missed some thing i dont want tto use propfile property in webconfg file
Try calling: Profile.Save(); after setting values for your profile...
-
Try calling: Profile.Save(); after setting values for your profile...
Thank for your answer But i have one question what does profile.save do does it save the data in the database or where does it save
-
Thank for your answer But i have one question what does profile.save do does it save the data in the database or where does it save
It updates the current profile with the values provided. It saves to the SQLEXPRESS database(ASPNETDB)in your local App_Data folder (by default).