remove "ReturnUrl=" from url

C

Chicagoboy27

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

Ken Cox [Microsoft MVP]

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]
 
C

Chicagoboy27

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>
said:
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 said:
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.
 
K

Ken Cox [Microsoft MVP]

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]
 
C

Chicagoboy27

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

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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top