Is there an easy way to get forms authentication to ignore the returnURL?
So the user clicks a link, the site timesout, they get redirected to my login page (which appends ReturnUrl to the URL) - I don't want this to happen, or for it to be ignored when they login again.
One option is to have some code in your login form's code-behind that does the following:
if (!string.IsNullOrEmpty(Request.QueryString["returnUrl"]))
{
Response.Redirect("path/to/my/login.aspx");
}
In other words, check in your login page for the presence of the returnUrl querystring parameter and if it's present, strip it out by redirecting back to yourself.
You can strip it off if you don't want to show it. I do that because I don't want it to show with SEO-friendly URLs that I have setup.
In the Global.asax
file put the following:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With