Copied to clipboard

Flag this post as spam?

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


  • anthony hall 217 posts 530 karma points
    Oct 09, 2009 @ 09:13
    anthony hall
    0

    circular referenc Member.GetMemberFromLoginNameAndPassword

    I'm getting a circular reference error when i use

    Member.GetMemberFromLoginNameAndPassword(username, password)

    This is odd, as it was working and i can't put my finger on what has changed. 

    I've read that a similar post here.  I tried the standard asp,net 

    Membership.ValidateUser(username, password); 

    But that seemed create the same error. Any feed back would be much appreciated. I just need a way to log users in. 

    anthony

     

       Member memberFromLoginNameAndPassword = Member.GetMemberFromLoginNameAndPassword(username, password);

                if (memberFromLoginNameAndPassword != null)

                {

                    Member.AddMemberToCache(memberFromLoginNameAndPassword, m_useSession, new TimeSpan(0, m_timeout, 0));

                }

  • skiltz 501 posts 701 karma points
    Oct 09, 2009 @ 09:24
    skiltz
    1

    You can just use the asp.net member login control <asp:login />

  • anthony hall 217 posts 530 karma points
    Oct 09, 2009 @ 09:33
    anthony hall
    0

    Actually i should add some more info. 

    I have the following fields in my usercontrol. 

    username | password | Email | Address1 | Address 2 | Custom etc 

    I'm saving this extra info as member nodes. 

     m = Member.GetMemberFromLoginName(memberLogin);

    m.getProperty("address1") = "etc";

  • skiltz 501 posts 701 karma points
    Oct 09, 2009 @ 10:42
    skiltz
    1

    I did this with osMemberControl (osmembercontrols.codeplex.com) maybe you could download the source and use the bits you need?  Look in the MemberRegistration.cs file. 

  • anthony hall 217 posts 530 karma points
    Oct 09, 2009 @ 14:57
    anthony hall
    0

    any further thoughts in this. How do i validate a user login.It seems the following method doesn't seem to work in  4.0.2.1

    Member.GetMemberFromLoginNameAndPassword(username, password)

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Oct 09, 2009 @ 16:32
    Nik Wahlberg
    0

    Hi Anthony, I solved this by applying some code in the login action (code behind). This should do what you need until the circular reference issue has been solved:

            protected void Login1_LoggedIn(object sender,EventArgs e)
            {
                TextBox unameTB = (TextBox)Login1.FindControl("Username");
                TextBox passwordTB = (TextBox)Login1.FindControl("Password");

                // at this point the user should be logged in
                Member m = Member.GetMemberFromLoginNameAndPassword(unameTB.Text, passwordTB.Text);
                MemberDB memberDb = new MemberDB();
                StaticMember sm = memberDb.GetMemberDetails(m.Id.ToString());
               
                // First, check to see if the user is active and that he is not expired
                if (sm.IsActive!=1)
                {
                    Response.Redirect("/logout.aspx?active=0"); // this is where I call the logout action in order to kill the user session...a little hacky but it works
                }

                // set session vars....
                SessionHandler.EmailAddress = sm.EmailAddress;
                SessionHandler.MemberType = sm.MemberTypeId.ToString();
                SessionHandler.Name = sm.Name;
                SessionHandler.IsExpired = "false";

                // check if the user has expired ans set appropriately...
                if (sm.MembershipTerm.IndexOf("Free")==-1)
                {
                    DateTime now = DateTime.Now;
                    if (sm.ExpirationDate.CompareTo(now) < 0)
                    {
                        // the account is expired so set the session as such...
                        SessionHandler.IsExpired = "true";
                    }
                }
            }

    Hope this helps.

    -- Nik

  • anthony hall 217 posts 530 karma points
    Oct 09, 2009 @ 18:18
    anthony hall
    0

    hi nik , i saw your solution.  Does this only work on Login Control or can i use this on normal onclick event. 

    I was puzzle why your method worked. ie when i hit GetMemberFromLoginNameAndPassword that is when the error happens.

    Thanks for your reply, this is driven me crazy. 

     

     Member m = Member.GetMemberFromLoginNameAndPassword(unameTB.Text, passwordTB.Text);

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Oct 10, 2009 @ 02:28
    Nik Wahlberg
    0

    Hi Anthony, this method has no problems within the context of the supplied membership provider. The error (at least for me) that you are experiencing happens when trying to extend that provider and override the validate method. Are you seeing the circular reference behaviou even in your code-behind?

    -- Nik

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies