4 Replies - 1262 Views - Last Post: 30 April 2010 - 05:46 PM Rate Topic: -----

#1 Guest_buddy*


Reputation:

login control related headache

Posted 30 April 2010 - 11:09 AM

Hi, I have a login control, with validated usernames and passwords, but it wont let me login, saying that the username and passwords dont match. Here is my code :

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {

    }

    protected void getUsername(object sender, EventArgs e)
    {
        string _username = Login1.UserName;
        System.IO.StreamWriter StreamWriter1 =
        new System.IO.StreamWriter(Server.MapPath("results.txt"), true);
        StreamWriter1.WriteLine(_username + "'s games");
        StreamWriter1.Close();
    }
}



note: it worked fine until I added the getUsername function which I needed to grab the user's username. Whats going on here?

Thanks very much!

Is This A Good Question/Topic? 0

Replies To: login control related headache

#2 Guest_buddy*


Reputation:

Re: login control related headache

Posted 30 April 2010 - 12:02 PM

no takers on this?

Putting it in the page_load or Login_Authenticate won't help either...
Was This Post Helpful? 0

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: login control related headache

Posted 30 April 2010 - 02:46 PM

Which event is getUsername tied to?
Was This Post Helpful? 0
  • +
  • -

#4 Guest_buddy*


Reputation:

Re: login control related headache

Posted 30 April 2010 - 03:44 PM

Ok I have this :

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        if (Membership.ValidateUser(Login1.UserName, Login1.Password))
        {
            FormsAuthentication.SetAuthCookie(Login1.UserName, true);
            

        }
        string _username = Login1.UserName;
        System.IO.StreamWriter StreamWriter2 =
        new System.IO.StreamWriter(Server.MapPath("results.txt"), true);
        StreamWriter2.WriteLine("hello" + _username);
        StreamWriter2.Close();
    }


Which will write the StreamWriter2to the file, will not recognize the login details, even though they are correct and work without the Login Authentication function.
Was This Post Helpful? 0

#5 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: login control related headache

Posted 30 April 2010 - 05:46 PM

Can you post the source of the page in question (ASPX)?

I am not sure why your authentication is not working correctly.

What steps did you follow to implement Membership and Authentication?

You might want to check out the following tutorial on implementing Membership. Since you are having validation issues.

Creating a Web Site with Membership and User Login
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1