Can forms authentication ignore returnUrl

Is there an easy way to get forms authentication to ignore returnURL?

Thus, the user clicks the link, the schedule on the site, they are redirected to my login page (which adds ReturnUrl to the URL) - I do not want this to happen, or to be ignored when I re-enter the system.

+5
source share
3 answers

One option is to have code in your code to log in to the system, which performs the following actions:

if (!string.IsNullOrEmpty(Request.QueryString["returnUrl"]))
{
    Response.Redirect("path/to/my/login.aspx");
}

, quurystring returnUrl, , , .

+3

, . , , SEO URL-, .

Global.asax :

Protected Sub Application_EndRequest(sender As Object, e As System.EventArgs)

        Dim redirectUrl As String = Me.Response.RedirectLocation
        If Not Me.Request.RawUrl.Contains("ReturnUrl=") AndAlso Not String.IsNullOrEmpty(redirectUrl) Then
            Me.Response.RedirectLocation = Regex.Replace(redirectUrl, "\?ReturnUrl=(?'url'[^&]*)", String.Empty)
        End If

End Sub
+3

All Articles