OnAuthenticate Login Control
<p>Could someone help me authenticate a user on OnAuthenticate Im have problems logging in. For some reason FormsAuthentication.Authenticate isn't working but membership.ValidateUser is
. Also if someone can expand on this please do I don't know if i've got everthing sorted I've never done this part before. Leave a comment and suggestions.</p>

<pre><code>protected void LoginUser_OnAuthenticate(object sender, AuthenticateEventArgs e)
{
    TextBox UserName = LoginUser.FindControl("UserName") as TextBox;
    TextBox Password = LoginUser.FindControl("Password") as TextBox;                  

    if (Membership.ValidateUser(UserName.Text, Password.Text))
    {
        FormsAuthentication.SetAuthCookie(UserName.Text, true);

        ProfileCommon profile = Profile.GetProfile(UserName.Text);
        profile.Visits += 1;
        profile.Save();

        e.Authenticated = true;

        if (Request.QueryString["ReturnUrl"] != null)
        {
            Response.Redirect(Request.QueryString["ReturnUrl"]);
        }
        else
        {
            FormsAuthentication.RedirectFromLoginPage(UserName.Text, true);                
        }
    }

}
</code></pre>
