Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael Perry 11 posts 43 karma points
    Feb 15, 2011 @ 20:43
    Michael Perry
    0

    Error creating members programmatically in 4.5.2 with .NET 4.0

    I am trying to progammatically create members using an asp:CreateUserWizard. Eventually I would like to use a user control for creating members, but for now I have the CreateUserWizard in a template.  The code is below:

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>

      <script runat="server">

    protected void registrationWizard_CreatedUser(object sender, EventArgs e)
    {
        Roles.AddUserToRole(registrationWizard.UserName, "Managers");
    }

    protected void registrationWizard_ContinueButtonClick(object sender, EventArgs e)
    {
      Response.Redirect("/");
    }

    </script>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
      
      
    <form id="testForm" runat="server">
      <asp:CreateUserWizard ID="registrationWizard" OnContinueButtonClick="registrationWizard_ContinueButtonClick" OnCreatedUser="registrationWizard_CreatedUser" runat="server">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"></asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"></asp:CompleteWizardStep>
        </WizardSteps>
      </asp:CreateUserWizard>
      </form>
    </asp:content>

    This code is tested and works as expected when using umbraco 4.5.2 with .NET 3.5.  However when I use the same code with .NET 4.0, I recieve an YSOD "Duplicate User name! A member with the user name xxxxxxx already exists" regardless of what user name I enter.

    As far as I can tell, the only difference between the site where this code works and the site where it doesn't work is that one is .NET 3.5 and the other is .NET 4.0.

    Has anyone had any luck programmatically creating members in Umbraco with .NET 4.0?

    Thanks in advance!

    --Mike

     

     

     

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 15, 2011 @ 21:01
    Jonas Eriksson
    0

    Hi, can it be you have an erroneous member with blank name in the db? I believe I saw that error msg in such a case.

    Regards

    Jonas

  • Michael Perry 11 posts 43 karma points
    Feb 15, 2011 @ 22:37
    Michael Perry
    0

    Thank you Jonas.  You were exactly right.  Once I deleted the meber with the blank login name from the database, I was able to get past this error and continue troubleshooting my programmatic membership creation. 

    Thanks again for the quick response!

    --Mike

Please Sign in or register to post replies

Write your reply to:

Draft