none
How to access Profiles from a provider that is NOT the default profile provider RRS feed

  • Question

  • I apologize in advance for asking what I know is a dumb question, but I can't figure out how to do it.

     

    I currently have a user base using Membership provider and the standard Profile provider. I have written a Custom Profile Provider (or at least enough of it is written that it can be used). Now my problem is I want to copy all the information from the current default provider to the new provider. I figured I could do something like.....

     

    MembershipUserCollection muc = Membership.GetAllUsers();

    foreach (MembershipUser u in muc)

    {

    ProfileCommon p = Profile.GetProfile(u.UserName);

    ProfileCommon pnew = ????????? // Instantiate a new profile tied to the NEW provider

    // transfer all the info from old to new .....

    pnew.FirstName = p.FirstName; // etc

    pnew.Save();

    }

     

    What I am having a problem with is the part where the question marks are. How do I instantiate a ProfileCommon object that is tied to my new provider rather than the default provider?

     

    I assume that I can instantiate an instance of my provider by...

     

    SettingsProvider myProvider = p.Providers["myProvider"];

     

    and then I could call SetPropertyValues on it but there seems to me it should be possible to use the standard ProfileCommon instance.

     

    The real reason why I want to know the answer is because clearly there is a gap in my understanding which I would like to fill.

     

    Thanks in advance

     

    Tuesday, January 22, 2008 8:37 PM

Answers

  • (and then I could call SetPropertyValues on it but there seems to me it should be possible to use the standard ProfileCommon instance.)

     

     

    Here is an alternative profile provider with implementation documentation and code from the Asp.net team because of the above problem.  You can use the alternative in just minutes, I have helped developers use it because most changes is just ALTER stored procedure.


    http://www.asp.net/downloads/sandbox/table-profile-provider-samples/

     

    Tuesday, January 22, 2008 11:31 PM

All replies

  • (and then I could call SetPropertyValues on it but there seems to me it should be possible to use the standard ProfileCommon instance.)

     

     

    Here is an alternative profile provider with implementation documentation and code from the Asp.net team because of the above problem.  You can use the alternative in just minutes, I have helped developers use it because most changes is just ALTER stored procedure.


    http://www.asp.net/downloads/sandbox/table-profile-provider-samples/

     

    Tuesday, January 22, 2008 11:31 PM
  • Many thanks for this response. This is indeed a superior solution to the one I had implemented and I think I will use it. However, unless I am missing something, the problem still remains. How do I move the data from the old Profile Store to the new Profile Store?

     

    Obviously, I could create the new table and then read all the profiles and store each profile in the SQL table using a SQL insert. But what I was trying to do was to read the profiles using the default provider and then write them using the new provider which is not YET the dafault. That's the piece of the puzzle I am missing.

     

     

     

    Wednesday, January 23, 2008 12:15 AM
  • Try these two but it only works with the default profile provider because most custom providers uses database tables which are very easy to move.

     

    http://jelle.druyts.net/2004/08/24/TheASPNET20Profile.aspx

     

    http://www.ondotnet.com/pub/a/dotnet/2004/10/25/libertyonwhidbey.html?page=last

     

    Wednesday, January 23, 2008 3:46 AM
  • I implemented the SQL Table Provider that was an MS Sample that you suggested yesterday. Then I populated the table using normal SQL. So even though I never directly solved my problem, it's all working.

     

    So I am a happy camper and I appreciate your help.

    Thursday, January 24, 2008 5:10 AM