asp.net Login Form

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

  1. engtota

    engtota

    Joined:
    Jan 21, 2009
    Messages:
    1
    Likes Received:
    0
    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. Advertisements

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. Abul Hasan Lakhani

    asp.net login form

    Abul Hasan Lakhani, Oct 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    718
    Sahil Malik
    Nov 1, 2004
  2. frekster
    Replies:
    1
    Views:
    1,182
    frekster
    Sep 14, 2005
  3. Alex via DotNetMonster.com

    Shared login for ASP.NET 1.1 ans ASP.NET 2.0

    Alex via DotNetMonster.com, Nov 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    567
    Alex via DotNetMonster.com
    Nov 14, 2005
  4. DavidADEW
    Replies:
    2
    Views:
    2,852
    DavidADEW
    Sep 1, 2006
  5. Sasquatch
    Replies:
    2
    Views:
    681
    Sasquatch
    Oct 4, 2006
  6. dev648237923
    Replies:
    3
    Views:
    665
    Steven Cheng[MSFT]
    Feb 9, 2007
  7. Randy Magruder
    Replies:
    3
    Views:
    567
    Randy Magruder
    Feb 14, 2007
  8. manu
    Replies:
    1
    Views:
    972
    Evans
    Jul 20, 2008
Loading...