Copied to clipboard

Flag this post as spam?

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


  • Mohsin 12 posts 71 karma points
    Jul 08, 2013 @ 09:21
    Mohsin
    0

    Object reference not set to an instance of an object during members registeration

    hi i am new to umbraco 

    ive recent made a login and signup page and use umbraco.cms.businesslogic.member.Member

    login is working prefectly fine

    but during registeration it gives error while checking for the previous existed users

    here is the Register.aspx.cs code

    {

    if (string.IsNullOrWhiteSpace(tbEmail.Text) | string.IsNullOrWhiteSpace(tbPassword.Text) | string.IsNullOrWhiteSpace(tbUsername.Text))

                {

                    litError.Text = string.Format(ErrorFormat, "Please complete all fields");

                    return;

                }

     

                // Check the user isn't already registered

                if ((Member.GetMemberFromEmail(tbEmail.Text) == null) && (Member.GetMemberFromLoginName(tbUsername.Text) == null))

                {

                    // Set the member type and group

                    var mt = MemberType.GetByAlias(MembersType);

                    var addToMemberGroup = MemberGroup.GetByName(MembersGroup);

     

                    //create the member, and set the password and email

                    var m = Member.MakeNew(tbUsername.Text, mt, new User(0));

                    m.Password = tbPassword.Text;

                    m.Email = tbEmail.Text;

     

                    // Add the member to the group

                    m.AddGroup(addToMemberGroup.Id);

     

                    //Save member

                    m.Save();

     

                    //Generate member Xml Cache

                    m.XmlGenerate(new System.Xml.XmlDocument());

     

                    // NOTE: This Is Optional

                    // Login the user

                    FormsAuthentication.SetAuthCookie(tbUsername.Text, false);

     

                    // Redirect to successful page (Usually their profile or member page)

                    Response.Redirect(library.NiceUrl(SuccessfulLoginPage));

                }

                else

                {

                    // Error, member already exists with email or username used

                    litError.Text = string.Format(ErrorFormat, "User already exists");

                }

    }

    it gives error on line that ive made BOLD

  • Theresa Danowski 16 posts 78 karma points
    Jul 08, 2013 @ 09:55
    Theresa Danowski
    0

    Good Morning Mohsin,

    I guess your first if does not work correctly by using just one | instead of || for the logic or

    Please try this line and tell me if it solve your problem:

    if (string.IsNullOrWhiteSpace(tbEmail.Text) || 
    string.IsNullOrWhiteSpace(tbPassword.Text) || 
    string.IsNullOrWhiteSpace(tbUsername.Text))
  • Mohsin 12 posts 71 karma points
    Jul 08, 2013 @ 10:32
    Mohsin
    0

    Thanks, Theresa

    but the problem lies between the lines ive mentioned

    see these images

    http://postimg.org/image/4xwtv7505/

    http://postimg.org/image/pjg70ubyt/

  • Mohsin 12 posts 71 karma points
    Jul 09, 2013 @ 13:03
    Mohsin
    100

    problem solved by changing type of defaultMemberTypeAlias to that i ve created in umbraco members panel

Please Sign in or register to post replies

Write your reply to:

Draft