remove "ReturnUrl=" from url

Discussion in 'ASP .Net' started by Chicagoboy27, Aug 29, 2006.

  1. Chicagoboy27

    Chicagoboy27 Guest

    All I am trying to find a solution for removing the ?returnUrl if a
    user is not authenticated. I want to be redirect an unauthenticated
    user to the login.aspx less the returnUrl.

    Once they log in I specifically want them to go to the default.aspx
    page and not the "ReturnUrl=" page. currently my sight is set up to
    redirect to the log in but I am looking to remove the ?returnurl so
    that it goes to the normal defualt.aspx

    Currently I am using asp.net 2.0
    forms authentication
    asp.net 2.0 built in log in controls.
     
    Chicagoboy27, Aug 29, 2006
    #1
    1. Advertising

  2. Is it that destinationpageurl="~/Default.aspx" doesn't work for you? That's
    the redirect target on successful login.

    Perhaps you could explain a little further or show us some code?

    <asp:login id="Login1" runat="server" displayrememberme="False"
    failuretext="Nope, that's not it!" destinationpageurl="~/Default.aspx">
    </asp:login>

    Ken
    Microsoft MVP [ASP.NET]

    "Chicagoboy27" <> wrote in message
    news:...
    > All I am trying to find a solution for removing the ?returnUrl if a
    > user is not authenticated. I want to be redirect an unauthenticated
    > user to the login.aspx less the returnUrl.
    >
    > Once they log in I specifically want them to go to the default.aspx
    > page and not the "ReturnUrl=" page. currently my sight is set up to
    > redirect to the log in but I am looking to remove the ?returnurl so
    > that it goes to the normal defualt.aspx
    >
    > Currently I am using asp.net 2.0
    > forms authentication
    > asp.net 2.0 built in log in controls.
    >
     
    Ken Cox [Microsoft MVP], Aug 29, 2006
    #2
    1. Advertising

  3. Chicagoboy27

    Chicagoboy27 Guest

    Below is the code that I am using: when a user goes to say page a.aspx
    and they are not logged in, it will redirect them to
    login.aspx?returnurl=a.aspx. When the user logs in successfully it does
    not take them to the DestinationPageUrl="~Default.aspx" but to the
    a.aspx page. I am looking to always have the user go to the
    default.aspx regardless of ?returnurl=a.aspx command


    <asp:Login ID="Login1" runat="server"
    DestinationPageUrl="~Default.aspx" DisplayRememberMe="False"
    BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4"
    BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
    Font-Size="0.8em" ForeColor="#333333" Width="250px">
    <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True"
    Font-Size="0.9em" ForeColor="White" />
    <InstructionTextStyle Font-Italic="True"
    ForeColor="Black" />
    <TextBoxStyle Font-Size="0.8em" />
    <LoginButtonStyle BackColor="#FFFBFF"
    BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
    Font-Names="Verdana" Font-Size="0.8em"
    ForeColor="#284775" />
    <LayoutTemplate>
    <table border="0" cellpadding="4" cellspacing="0"
    style="border-collapse: collapse">
    <tr>
    <td>
    <table border="0" cellpadding="0"
    style="width: 250px">
    <tr>
    <td align="center" colspan="2"
    style="font-weight: bold; font-size: 0.9em; color: white;
    background-color: #5d7b9d">
    Log In</td>
    </tr>
    <tr>
    <td align="right">
    <asp:Label
    ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
    Name:</asp:Label></td>
    <td tabindex="1">
    <asp:TextBox ID="UserName"
    runat="server" Font-Size="0.8em"></asp:TextBox>
    <asp:RequiredFieldValidator
    ID="UserNameRequired" runat="server" ControlToValidate="UserName"
    ErrorMessage="User Name
    is required." ToolTip="User Name is required."
    ValidationGroup="Login1">*</asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr>
    <td align="right">
    <asp:Label
    ID="PasswordLabel" runat="server"
    AssociatedControlID="Password">Password:</asp:Label></td>
    <td tabindex="1">
    <asp:TextBox ID="Password"
    runat="server" Font-Size="0.8em" TextMode="Password"
    Width="103px"></asp:TextBox>
    <asp:RequiredFieldValidator
    ID="PasswordRequired" runat="server" ControlToValidate="Password"
    ErrorMessage="Password
    is required." ToolTip="Password is required."
    ValidationGroup="Login1">*</asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr>
    <td align="center" colspan="2"
    style="color: red">
    <asp:Literal
    ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <table width="100%">
    <tr>
    <td>
    <asp:HyperLink
    ID="HyperLink1" runat="server" NavigateUrl="~/passwordrecovery.aspx"
    Font-Size="X-Small">Forgot your password?</asp:HyperLink>
    </td>
    <td>
    <asp:Button
    ID="LoginButton" runat="server" BackColor="#FFFBFF"
    BorderColor="#CCCCCC"

    BorderStyle="Solid" BorderWidth="1px" CommandName="Login"
    Font-Names="Verdana"

    Font-Size="0.8em" ForeColor="#284775" Text="Log In"
    ValidationGroup="Login1" OnClick="LoginButton_Click" />
    </td>
    </tr>
    </table>

    </td>
    </tr>

    </table>
    </td>
    </tr>
    </table>
    </LayoutTemplate>
    </asp:Login>
    Ken Cox [Microsoft MVP] wrote:
    > Is it that destinationpageurl="~/Default.aspx" doesn't work for you? That's
    > the redirect target on successful login.
    >
    > Perhaps you could explain a little further or show us some code?
    >
    > <asp:login id="Login1" runat="server" displayrememberme="False"
    > failuretext="Nope, that's not it!" destinationpageurl="~/Default.aspx">
    > </asp:login>
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    > "Chicagoboy27" <> wrote in message
    > news:...
    > > All I am trying to find a solution for removing the ?returnUrl if a
    > > user is not authenticated. I want to be redirect an unauthenticated
    > > user to the login.aspx less the returnUrl.
    > >
    > > Once they log in I specifically want them to go to the default.aspx
    > > page and not the "ReturnUrl=" page. currently my sight is set up to
    > > redirect to the log in but I am looking to remove the ?returnurl so
    > > that it goes to the normal defualt.aspx
    > >
    > > Currently I am using asp.net 2.0
    > > forms authentication
    > > asp.net 2.0 built in log in controls.
    > >
     
    Chicagoboy27, Aug 30, 2006
    #3
  4. Hi again,

    Okay, I see it now...

    I'd catch the LoggedIn event and hardcode a redirect to the desired page.
    Here's some code:

    Protected Sub Login1_LoggedIn _
    (ByVal sender As Object, _
    ByVal e As System.EventArgs)
    Response.Redirect("default.aspx")
    End Sub

    The query string still seems to show but the redirect takes precedence.

    Let us know if this helps?

    Ken
    Microsoft MVP [ASP.NET]

    "Chicagoboy27" <> wrote in message
    news:...
    > Below is the code that I am using: when a user goes to say page a.aspx
    > and they are not logged in, it will redirect them to
    > login.aspx?returnurl=a.aspx. When the user logs in successfully it does
    > not take them to the DestinationPageUrl="~Default.aspx" but to the
    > a.aspx page. I am looking to always have the user go to the
    > default.aspx regardless of ?returnurl=a.aspx command
    >
     
    Ken Cox [Microsoft MVP], Aug 31, 2006
    #4
  5. Chicagoboy27

    Chicagoboy27 Guest

    Thanks that worked like a charm.... Thank you so much for your
    time.....


    Ken Cox [Microsoft MVP] wrote:
    > Hi again,
    >
    > Okay, I see it now...
    >
    > I'd catch the LoggedIn event and hardcode a redirect to the desired page.
    > Here's some code:
    >
    > Protected Sub Login1_LoggedIn _
    > (ByVal sender As Object, _
    > ByVal e As System.EventArgs)
    > Response.Redirect("default.aspx")
    > End Sub
    >
    > The query string still seems to show but the redirect takes precedence.
    >
    > Let us know if this helps?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    > "Chicagoboy27" <> wrote in message
    > news:...
    > > Below is the code that I am using: when a user goes to say page a.aspx
    > > and they are not logged in, it will redirect them to
    > > login.aspx?returnurl=a.aspx. When the user logs in successfully it does
    > > not take them to the DestinationPageUrl="~Default.aspx" but to the
    > > a.aspx page. I am looking to always have the user go to the
    > > default.aspx regardless of ?returnurl=a.aspx command
    > >
     
    Chicagoboy27, Aug 31, 2006
    #5
    1. Advertising

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. Tomk

    ReturnURL

    Tomk, Jan 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    739
  2. AC
    Replies:
    0
    Views:
    540
  3. Gala Grant

    remove "ReturnUrl=" from url

    Gala Grant, Nov 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    856
    Patrick Olurotimi Ige
    Nov 26, 2004
  4. VB Programmer
    Replies:
    1
    Views:
    1,059
    Steve C. Orr [MVP, MCSD]
    Dec 8, 2004
  5. Randall Parker
    Replies:
    1
    Views:
    1,863
    Daniel Fisher\(lennybacon\)
    Dec 5, 2005
Loading...

Share This Page