Login Cotrols

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.
CPSRIAsked:
Who is Participating?
 
aswathiConnect With a Mentor Commented:
hi

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

               Response.Redirect("HomePage.aspx");
      }
}

Open in new window


0
 
guveraCommented:
Hi,

 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);
}
else
{
FormsAuthentication.SetAuthcookie(txtUserName.text, false);
Response.Redirect("CustomPage.aspx");
}
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.

0
 
CPSRIAuthor Commented:
Tank you .. from this code i identify the problem and solved it..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.