Web Application Projects and the ProfileCommon NOT working

Last post 11-11-2009 4:01 AM by bexasp. 11 replies.

Sort Posts:

  • Web Application Projects and the ProfileCommon NOT working

    03-24-2006, 9:10 AM
    • Member
      60 point Member
    • jwfransen
    • Member since 03-24-2006, 2:02 PM
    • amsterdam
    • Posts 12

    Hi all,

    We swapt to Web Application Project because that works nicely together with sourcegear. We run into the following problem.

    I'm retreiving some profile information of a specific user by:

    Dim u As MembershipUser = Membership.GetUser(gvUsers.SelectedRow.Cells(2).Text)
    Dim p As ProfileCommon = Profile.GetProfile(u.UserName)

    and then i have control over the users profile
    p.<property>=value
    etc

    This works fine when i'm not using a 'web application project' But when i use this project type i get a 'type profile common not defined' .. I have attached all in my opinion relevant namespaces.

    So any thoughts on this or a nice workaround how to get hold of the profiles from another user.

    thanks,

    -- jan willem

     


     

  • Re: Web Application Projects and the ProfileCommon NOT working

    03-27-2006, 3:05 PM
    • Member
      17 point Member
    • assemblage
    • Member since 06-25-2004, 10:44 AM
    • Posts 6

    I found the answer http://forums.asp.net/1141608/ShowPost.aspx.

    I'm working on a admin page and needed real names that's stored in the user profile.  This is how I got them in C#:

    ICollection CreateUserDataSource()
        {
            DataTable dt = new DataTable();
    
            dt.Columns.Add(new DataColumn("UserName", typeof(String)));
            dt.Columns.Add(new DataColumn("UserRealName", typeof(String)));
    
            Int32 pageIndex = 0;
            Int32 pageSize = 9;
            Int32 totalRecords = 0;
            MembershipUserCollection muc = Membership.GetAllUsers();
    
            foreach (MembershipUser mu in muc)
            {
                    ProfileCommon userProfile = (ProfileCommon)ProfileBase.Create(info.UserName);
            }
    
            DataView dv = new DataView(dt);
            return dv;
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            gvUsers.DataSource = CreateUserDataSource();
            gvUsers.DataBind();
        }
     
    another good article is here http://www.theserverside.net/articles/showarticle.tss?id=CreatingProfileProvider
  • Re: Web Application Projects and the ProfileCommon NOT working

    03-28-2006, 6:22 AM
    • Member
      60 point Member
    • jwfransen
    • Member since 03-24-2006, 2:02 PM
    • amsterdam
    • Posts 12

    Yeaa i found that one aswell before I dod this post. But that gives me the same error.

     

    ----jw

  • Re: Web Application Projects and the ProfileCommon NOT working

    03-28-2006, 10:51 AM
    • Member
      17 point Member
    • assemblage
    • Member since 06-25-2004, 10:44 AM
    • Posts 6
    I'm using web project & web form page.  I'm not sure if this will help, but here's a slightly different way 
    DataTable CreateUserDataSource2()
        {
            DataTable dt = new DataTable();
    
            dt.Columns.Add(new DataColumn("UserName", typeof(String)));
            dt.Columns.Add(new DataColumn("UserRealName", typeof(String)));
    
            ProfileInfoCollection profileColl = ProfileManager.GetAllProfiles(
                ProfileAuthenticationOption.Authenticated);
    
            foreach (ProfileInfo pi in profileColl)
            {
                ProfileCommon userProfile = (ProfileCommon)ProfileBase.Create(pi.UserName);
                DataRow dr = dt.NewRow();
                dr["UserName"] = userProfile.UserName;
                dr["UserRealName"] = userProfile.Name.lName + ", " + userProfile.Name.fName;
                dt.Rows.Add(dr);
            }
    
            return dt;
        }
    
        protected void GetProfiles()
        {
            gvUsers.DataSource = CreateUserDataSource2();
            gvUsers.DataBind();
        }
     
  • Re: Web Application Projects and the ProfileCommon NOT working

    03-28-2006, 4:48 PM
    • Member
      60 point Member
    • jwfransen
    • Member since 03-24-2006, 2:02 PM
    • amsterdam
    • Posts 12

    Hi I found the sollution (well I got a mail from scott telling me were to look .. )

    http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx alllllll the way down .. read the other stuff aswell it's very very usefull info.

    Thanks all for the input!

    -- jan willem

     

     

  • Re: Web Application Projects and the ProfileCommon NOT working

    04-01-2006, 10:17 AM
    • Member
      389 point Member
    • herensuge
    • Member since 06-18-2002, 8:37 AM
    • Spain
    • Posts 77
    jwfransen:

    Hi I found the sollution (well I got a mail from scott telling me were to look .. )

    http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx alllllll the way down .. read the other stuff aswell it's very very usefull info.

    I am working with VB and I try also to make what Scott Guthrie says at the previous link, but I allways get the ProfileCommon equals Nothing.

     I am working now with the VSWAP Preview and before I can get the Profile with data.

    Thanks for your help.

     

    Luis MartĂ­nez Aniesa (aka Herensuge)

    Non gogoa, han zangoa

    http://www.sareleku.com
  • Re: Web Application Projects and the ProfileCommon NOT working

    09-10-2007, 10:51 AM
    • Member
      14 point Member
    • secretxelf
    • Member since 08-27-2007, 5:01 PM
    • Nashville, TN
    • Posts 7

    Here is the solution to grabbing a different users profile if you are using a web application.  Enjoy!

     In most of the code examples you have seen they use a ProfileCommon class.  That is because they are working with a website and that class is created while they are still developing.  That is also why they get intellisense when using profiles.  When using a web app the code won't compile until run time so we don't get the intellisense and we don't get the ProfileCommon class.  ProfileCommon's base class is ProfileBase.  We can use this class the same way they were to an extent.  Just look at the sample code below.  I think it will make sense.

     

    Dim strUserName As String = Me.lstUsers.SelectedValue
    Dim userProfile As ProfileBase = ProfileBase.Create(strUserName, True) 'if the user already has a profile this will just grab their profile, it won't overwrite it, don't worry
    
    Me.txtFirstName.Text = userProfile.GetPropertyValue("FirstName")
    Me.txtLastName.Text = userProfile.GetPropertyValue("LastName")
    Me.txtEmailAddress.Text = Membership.GetUser(strUserName).Email 
      
  • Re: Web Application Projects and the ProfileCommon NOT working

    12-18-2007, 1:28 PM
    • Member
      132 point Member
    • TTETranscripts
    • Member since 04-14-2006, 8:54 PM
    • Illinois
    • Posts 58

    How would you go and add information to the profile from a CreateUserWizard.

    I am stuck at

    UserProfile.SetPropertyValue("FirstName", String) = FirstName.Text

    It doesn't like the propery 'String'.  Not sure what it is looking for.  Thanks, Mike

    I wish there was only one way to do something!!
    Need a transcription? - http://www.ttetranscripts.com
  • Re: Web Application Projects and the ProfileCommon NOT working

    02-09-2008, 7:49 AM
    • Member
      123 point Member
    • degt
    • Member since 11-27-2002, 5:43 AM
    • Den Haag,The Netherlands
    • Posts 122

    Obviously that is not an answer, the original posting says clearly that the error message is that "ProfileCommon" is not found. The response given works fine for "Web Site projects" and not for "Web Application projects".

     In website projects ProfileCommon is automatically generated but that is not so (what on earth were MS developers thinking?) in Web Applications. One of those things where incompatibilities are introduced for absolutely no reason.


  • Re: Web Application Projects and the ProfileCommon NOT working

    04-03-2008, 3:15 PM
    • Member
      239 point Member
    • lprigmore
    • Member since 08-11-2005, 7:44 PM
    • Houston, TX -- Highland Village
    • Posts 52

    degt:
    In website projects ProfileCommon is automatically generated but that is not so (what on earth were MS developers thinking?) in Web Applications.

    Does this mean that a developer cannot access "ProfileCommon" in a WebApplication project or is there a workaround?

  • Re: Web Application Projects and the ProfileCommon NOT working

    04-03-2008, 3:15 PM
    • Member
      239 point Member
    • lprigmore
    • Member since 08-11-2005, 7:44 PM
    • Houston, TX -- Highland Village
    • Posts 52

    degt:
    In website projects ProfileCommon is automatically generated but that is not so (what on earth were MS developers thinking?) in Web Applications.

    Does this mean that a developer cannot access "ProfileCommon" in a WebApplication project or is there a workaround?

  • Re: Web Application Projects and the ProfileCommon NOT working

    11-11-2009, 4:01 AM
    • Member
      6 point Member
    • bexasp
    • Member since 10-24-2009, 11:32 AM
    • Posts 27

    hi there did you solve this problem?

    if so how?

     

     

Page 1 of 1 (12 items)