Link to home
Start Free TrialLog in
Avatar of mj168
mj168

asked on

Problems with the ReturnURL

I have an index page with a LoginStatus control. See below. When the visitor clicks on 'Login' the visitor is taken to the Login page.

<asp:LoginStatus ID="LoginStatus1" runat="server"
                            LogoutAction="RedirectToLoginPage" Font-Bold="True" Font-Names="Arial"
                            Font-Size="Small" ForeColor="#0000CC" />

On the Login page there is a Login control. See below. The problem I am having is that when the visitor correctly enters their login information and clicks the 'Login' button. The user is taken back to the index page and not the page assigned to the 'DestinationPageURL' property.

<asp:Login ID="Login1" runat="server"
                                        DisplayRememberMe="False" PasswordRecoveryText="Forgot Password?"
                                        PasswordRecoveryUrl="~/gp.aspx"
                                        DestinationPageUrl="~/useraccount.aspx">
                                    </asp:Login>

Thanks in advance.
Avatar of urir10
urir10

have u chekced that <authentication> tag in web.config file?
Avatar of mj168

ASKER

Below is my <authentication> tag.

<authentication mode="Forms">
Avatar of mj168

ASKER

Ignore the above. Below is my <authentication> tag.

<authentication mode="Forms">
   <forms defaultUrl="login.aspx" />
</authentication>
try to attach the login event to the login control and redirect from code behind like this :


                   
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

{

                      Response.Redirect(ResolveClientUrl(Login1.DestinationPageUrl));

}

Open in new window

Avatar of mj168

ASKER

I tried the code you gave:

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
        Response.Redirect(ResolveClientUrl(Login1.DestinationPageUrl))
    End Sub

There are still problems. While It does go to the destination page url, the username that is supposed to display on the page does not show and also the login status displays "login", instead of "logout". It seems that redirecting in the login authentication event does not log the user in.

Below are code snippets for the loginview and loginstatus that are on the destination page url.
LoginView
<asp:LoginView ID="LoginView1" runat="server">
                            <LoggedInTemplate>
                                Welcome,                                
                            </LoggedInTemplate>                            
                        </asp:LoginView>
                        <asp:LoginName ID="LoginName1" runat="server" />

LoginStatus
<asp:LoginStatus ID="LoginStatus1" runat="server"
                            LogoutAction="RedirectToLoginPage" Font-Bold="True" Font-Names="Arial"
                            Font-Size="Small" ForeColor="#0000CC" />
ASKER CERTIFIED SOLUTION
Avatar of urir10
urir10

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial