why after I log out my website and log in again. the last page that I logged out on thats the page I am redirected to...

why after I log out my website and log in again. the last page that logged out on thats the page I am redirected to...when logged in again. I thougt when you login though thr login control it goes to the assigned destination page. well, my website is not doing that. whatever page the user has last visited and the user decides to login again thats the page the user will be redirected to after they login. I am using the person website starter template. any ideas why this happens and/or how to fix it?

0 cluce 7/23/2008 6:53:27 PM

This is the default behaviour of login control , it redirect back the user to the page that **** was viewing it , this behaviour exists to redirect the user back to the page that **** was working on,

if you want to overried this behaviour , you can handle the loggedin event for yur login control and use response.redirect to always send the user to a specific page .

 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0 anas 7/23/2008 7:15:34 PM

where exactly is this event"loggedin event "?

0 cluce 7/23/2008 7:24:21 PM

Through the control properties , go to events and click on the LoggedIn event , this will automaticly creates a function in the code behind , add the reponse.redirect  code there


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0 anas 7/23/2008 7:31:20 PM

really? this is the properties through teh login control? If so, I dont see an event setting?? I looked in the beahvior section and else where. I have no luck. do you have an example of the tag element where this may be located at? thanks

0 cluce 7/23/2008 7:46:46 PM

IN VB :

                
0 anas 7/24/2008 1:22:18 PM

Hi

try this:

protected void Login1_LoggedIn(object sender, EventArgs e)

{

TextBox TextBox1 = (TextBox)Login1.FindControl("UserName");

//MembershipUser user = Membership.GetUser(TextBox1.Text);

MembershipUser user = Membership.GetUser(Login1.UserName);if (Request.QueryString["ReturnUrl"] != null)

{

Response.Redirect(Request.QueryString[
"ReturnUrl"].ToString());

}

else

{

//-- check if login user in Admin role

if (Roles.IsUserInRole(TextBox1.Text, "Admin"))

{

Response.Redirect(
"~/Admin/Default.aspx");

}

//-- check if login user in User role

else if (Roles.IsUserInRole(TextBox1.Text, "User"))

{

Response.Redirect(
"~/User/Default.aspx");

}

}

 

}

Good Luck

0 yasserzaid 7/25/2008 1:15:06 PM

and if you want to handle Error of Login User

try this:

protected void Login1_LoginError(object sender, EventArgs e)
    {
        //There was a problem logging in the user

        //See if this user exists in the database
        MembershipUser userInfo = Membership.GetUser(Login1.UserName);

        if (userInfo == null)
        {
            //The user entered an invalid username...

            Login1.FailureText = "There is no user in the database with the username " + Login1.UserName;
        }
        else
        {
            //See if the user is locked out or not approved
            if (!userInfo.IsApproved)
            {

                Login1.FailureText = "Your account has not yet been approved by the site's administrators. Please try again later...";
            }
            else if (userInfo.IsLockedOut)
            {
                Login1.FailureText = "Your account has been locked out because of a maximum number of incorrect login attempts. You will NOT be able to login until you contact a site administrator and have your account unlocked.";
            }
            else
            {
                //The password was incorrect (don't show anything, the Login control already describes the problem)
                Login1.FailureText = string.Empty;
            }
        }

}

Good Luck

0 yasserzaid 7/25/2008 1:23:20 PM

I used your login1_LoggedIn event and I am getting this error..

Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. 

0 cluce 7/26/2008 12:51:34 AM

It seems that you placed the login control inside a nother cotrol like loginview ....

Please remove Handles clause from the event handler like this

    Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
        Response.Redirect("SmePage.aspx")
    End Sub

And In the login control , assign the handler declarativle like this :

<asp:Login ID="Login1" runat="server" OnLoggedIn="Login1_LoggedIn">

asp:Login>


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

0 anas 7/26/2008 12:37:01 PM

thanks. I had a feeling it was something like that. just wasnt sure how to fix it. I am still learning how to do these custom Protected Sub procedures.  it works now.

0 cluce 7/28/2008 2:01:38 AM
Reply:

(Thread closed)