Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep my Login.aspx page's ReturnUrl parameter from overriding my ASP.NET Login control's DestinationPageUrl property?

I'm using the ASP.NET Login Controls and Forms Authentication for membership/credentials for an ASP.NET web application. I've got pages such as PasswordRecovery.aspx that are accessable to only Anonymous users. When I click my login link from such a page, the login page has a ReturnUrl parameter in the address bar:

http://www.example.com/Login.aspx?ReturnUrl=PasswordRecovery.aspx

And then after a successful login, users are returned to the PasswordRecovery.aspx page specified in the ReturnUrl parameter to which they no longer have access.

like image 630
Zack Peterson Avatar asked Aug 28 '08 19:08

Zack Peterson


People also ask

How do I remove ReturnUrl from URL?

if you are using asp.net control loginstatus then click on login status control press f4( for properties) under behavior section we can see LogOutAction there select Return to Login page. Show activity on this post. If you want to remove returnURL from request and redirect to specific path, you can follow this steps.

What does ReturnUrl mean?

A return URL redirects users back to the originating page during a checkout flow.

What is MVC ReturnUrl?

The Forms Authentication makes use of ReturnUrl parameter to redirect user to the requested page after Login in ASP.Net MVC.


1 Answers

I found the answer on Velocity Reviews. I handled the LoggedIn event to force a redirection to the DestinationPageUrl page.

Public Partial Class Login
    Inherits System.Web.UI.Page

    Protected Sub Login1_LoggedIn(ByVal sender As Object, _  
            ByVal e As System.EventArgs) Handles Login1.LoggedIn
        'overrides ReturnUrl page parameter
        Response.Redirect(Login1.DestinationPageUrl)
    End Sub

End Class
like image 77
Zack Peterson Avatar answered Oct 05 '22 22:10

Zack Peterson