asp.net Login Form

Discussion in '.NET' started by engtota, Jan 21, 2009.

  1. engtota

    engtota

    Joined:
    Jan 21, 2009
    Messages:
    1
    Hi all this is my first question in here ...

    i'm using asp.net authentication form ... and i need to handle a special case

    in case the index.aspx page is opened with a URL which includes a certain querystring ,,, i automatically make that user loggedin but it never work for me

    what i did is that ...

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    string userID = Request.QueryString["username"];
    if (!String.IsNullOrEmpty(userID))
    {
    Guid gd = new Guid(userID.Trim());

    if (!(gd == null))
    {
    MembershipUser user = Membership.GetUser(gd);
    if (Membership.ValidateUser(user.UserName, "123456"))
    {


    Login ctllogin = (Login)LoginView1.FindControl("Login1");
    TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
    TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");

    txtuser.Text = user.UserName;
    txtpwd.Attributes.Add("Value", "123456");
    Button btnLogin = (Button)ctllogin.FindControl("LoginButton");

    btnLogin.Click += new System.EventHandler(LoginButton_Click);
    LoginButton_Click(btnLogin, e);

    }
    }
    }
    }

    }

    then i forced the call of the Button Login click

    protected void LoginButton_Click(object sender, EventArgs e)
    {

    string userID = Request.QueryString["username"];
    if (!String.IsNullOrEmpty(userID))
    {
    Guid gd = new Guid(userID.Trim());

    if (!(gd == null))
    {
    MembershipUser user = Membership.GetUser(gd);
    if (Membership.ValidateUser(user.UserName, "123456"))
    {
    AuthenticateEventArgs eArg = new AuthenticateEventArgs();
    Login_Authenticate(sender, eArg);
    }
    }

    }

    }

    but even by forcing the button click it didnt fire the event logged_IN so i called the event

    protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
    {
    string userID = Request.QueryString["username"];
    if (!String.IsNullOrEmpty(userID))
    {
    Guid gd = new Guid(userID.Trim());

    if (!(gd == null))
    {
    MembershipUser user = Membership.GetUser(gd);
    if (Membership.ValidateUser(user.UserName, "123456"))
    {


    Login ctllogin = (Login)LoginView1.FindControl("Login1");
    TextBox txtuser = (TextBox)ctllogin.FindControl("UserName");
    TextBox txtpwd = (TextBox)ctllogin.FindControl("Password");

    txtuser.Text = user.UserName;
    txtpwd.Attributes.Add("Value", "123456");

    e.Authenticated = true;
    FormsAuthentication.RedirectFromLoginPage(txtuser.Text, false);
    }
    }
    }

    but even that didnt enable me to make that user's status to be logged_in what is missing in here ??

    please help .. than on advanced
    engtota, Jan 21, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. frekster
    Replies:
    1
    Views:
    922
    frekster
    Sep 14, 2005
  2. DavidADEW
    Replies:
    2
    Views:
    2,694
    DavidADEW
    Sep 1, 2006
  3. Sasquatch
    Replies:
    2
    Views:
    1,281
    Sasquatch
    Oct 3, 2006
  4. Sasquatch
    Replies:
    2
    Views:
    441
    Sasquatch
    Oct 4, 2006
  5. manu
    Replies:
    1
    Views:
    774
    Evans
    Jul 20, 2008
Loading...

Share This Page