Login Cotrols

Posted on 2011-04-24
Last Modified: 2012-05-11
Hi i am new to Login Controls .I used TextBox controls and button event . In Button Event 'login' command Used.Now My intention is how can i redirect the page like 'Default.aspx'  in login Page.
could any help to over come this problem.
Thanks in advance.
Question by:CPSRI
    LVL 8

    Expert Comment


     While using ASP.NET Forms authentication, if we try to access a protected page, the user would be taken to the login.aspx page with the ReturnUrl parameter having the path for the originally requested page.

    Once, the user's credentials are verified, the RedirectFromLoginPage method can be used to take the user back to the originally requested page.

    However, if there is no specified ReturnUrl, then FormsAuthentication by default takes the user to the default.aspx page upon successful authentication.

    If we do not have a default.aspx page or we want to take the users to our custom page etc., then we can use the Setauthcookie method to set the cookie and then redirect users to our desired page. The following code establishes the same.

    // Once the user's entered credentials are verified //
    if(Request.Params["ReturnUrl"] != null)
    FormsAuthentication.RedirectFromLoginPage(txtUserName.text, false);
    FormsAuthentication.SetAuthcookie(txtUserName.text, false);
    The above code first verifies whether there is any ReturnUrl parameter such that if exists, it should take to the originally requested page.

    Else, it sets the authcookie and then redirects user to a custom page.

    The txtUserName is the ID of the textbox which is used to capture the username.

    LVL 2

    Accepted Solution


     try this code
      protected void LoginControl_Authenticate(object sender, AuthenticateEventArgs e)
          if (userSP.UserNameCheck(LoginControl.UserName, LoginControl.Password)) // Check entered   
                                                                                                        //username & password are correct

    Open in new window


    Author Closing Comment

    Tank you .. from this code i identify the problem and solved it..

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This video teaches users how to migrate an existing Wordpress website to a new domain.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now