Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Using profile as custom class (getting null while taking data from profile _

Using profile as custom class (getting null while taking data from profile _

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justintimberlake
    wrote on last edited by
    #1

    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

    I 1 Reply Last reply
    0
    • J justintimberlake

      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

      I Offline
      I Offline
      Ibrahim Bello
      wrote on last edited by
      #2

      Try calling: Profile.Save(); after setting values for your profile...

      J 1 Reply Last reply
      0
      • I Ibrahim Bello

        Try calling: Profile.Save(); after setting values for your profile...

        J Offline
        J Offline
        justintimberlake
        wrote on last edited by
        #3

        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

        I 1 Reply Last reply
        0
        • J justintimberlake

          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

          I Offline
          I Offline
          Ibrahim Bello
          wrote on last edited by
          #4

          It updates the current profile with the values provided. It saves to the SQLEXPRESS database(ASPNETDB)in your local App_Data folder (by default).

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups