• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

Need to show user profile information of a class.

I have the following:
how can I show the user information:

using System;
using System.Web;
using System.IO;
using System.Xml.Serialization;
using System.Web.Caching;
 
public static class UserProfile
{
    public class Personal
    {
        public static System.String UserName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("UserName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("UserName", value); }
        }
 
        public static System.String Password
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Password") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Password", value); }
        }
 
        public static System.String Email
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Email") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Email", value); }
        }
 
        public static System.String FirstName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("FirstName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("FirstName", value); }
        }
 
        public static System.String LastName
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("LastName") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("LastName", value); }
        }
 
        public static System.DateTime DOB
        {
            get { return (System.DateTime)HttpContext.Current.Profile.GetPropertyValue("DOB"); }
            set { HttpContext.Current.Profile.SetPropertyValue("DOB", value); }
        }
 
        public static System.Int32? Age
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Age") as System.Int32?; }
            set { HttpContext.Current.Profile.SetPropertyValue("Age", value); }
        }
 
        public static System.String Gender
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Gender") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Gender", value); }
        }
 
        public static System.String Seeking
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Seeking") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Seeking", value); }
        }
 
        public static System.String ConfirmationGUID
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("ConfirmationGUID") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("ConfirmationGUID", value); }
        }
 
        public static System.String UserIP
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("UserIP") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("UserIP", value); }
        }
 
        public static System.String SessionID
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("SessionID") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("SessionID", value); }
        }
 
    }
    public class Address
    {
        public static System.String Country
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Country") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Country", value); }
        }
 
        public static System.String Region
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Region") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Region", value); }
        }
 
        public static System.String City
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("City") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("City", value); }
        }
 
        public static System.String ZipCode
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("ZipCode") as System.String; }
            set { HttpContext.Current.Profile.SetPropertyValue("ZipCode", value); }
        }
 
    }
    public class Preferences
    {
        public static String Theme
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Theme") as String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Theme", value); }
        }
 
        public static String Culture
        {
            get { return HttpContext.Current.Profile.GetPropertyValue("Culture") as String; }
            set { HttpContext.Current.Profile.SetPropertyValue("Culture", value); }
        }
 
    }
    public static void Save()
    {
        HttpContext.Current.Profile.Save();
    }
}

Open in new window

0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 4
1 Solution
 
nmarunCommented:
Your definition of a class is incorrect. You have defined a class inside a class. What is it that you are trying to do?
0
 
mathieu_cuprykAuthor Commented:
to create a userprofile class related to the web.config.
0
 
aibusinesssolutionsCommented:
It looks like you are looking to create a custom profile provider.

To link it to your web.config file, you would need to do something like this, specifically setting the "defaultProvider" to point to your class name.

<profile defaultProvider="UserProfile">
  <properties>
     <add name="UserName" />
     <add name="Password" />
     etc, etc, etc,
  </properties>
</profile>
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mathieu_cuprykAuthor Commented:
i created a customer provider for my web.config.
now I would liket to create a method to show user
0
 
mathieu_cuprykAuthor Commented:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


/// <summary>
/// Summary description for Personal
/// </summary>
[Serializable()]
public class Personal
{
    public Personal() { }

    public Personal

        (string username,
         string password,
         string email,
         string firstname,
         string lastname,
         DateTime dob,
         Int32? age,
         string gender,
         string seeking,
         string confirmationguid)
    {
        this.UserName = username;
        this.Password = password;
        this.Email = email;
        this.FirstName = firstname;
        this.LastName = lastname;
        this.DOB = dob;
        this.Age = age;
        this.Gender = gender;
        this.Seeking = seeking;
        this.ConfirmationGUID = confirmationguid;
    }    

    private string username = "";
    public string UserName
    {
         get { return username;}
         set { username = value;}
    }

    private string password = "";
    public string Password
    {
        get { return password;}
        set { password = value;}
   }

    private string email = "";
    public string Email
    {
        get { return email;}
        set { email = value;}
    }

    private string firstname = "";
    public string FirstName
    {
        get { return FirstName;}
        set { FirstName = value;}
    }

    private string lastname = "";
    public string LastName
    {
        get { return LastName;}
        set { LastName = value;}
    }

    private DateTime dob = DateTime.Now;
    public DateTime DOB
    {
        get { return DOB;}
        set { DOB = value;}
    }

    private Int32? age = 0;
    public Int32? Age
    {
        get { return Age;}
        set { Age = value;}
    }  

    private string gender = "";
    public string Gender
    {
        get { return Gender;}
        set { Gender = value;}  
    }

    private string seeking = "";
    public string Seeking
    {
        get { return Seeking;}
        set { Seeking = value;}
    }

    private string confirmationguid = "";
    public string ConfirmationGUID
    {
        get { return ConfirmationGUID;}
        set { ConfirmationGUID = value;}
 
    }


   
}
I need you to veify this
0
 
mathieu_cuprykAuthor Commented:
u are just providing a solution that i purposed in my question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now