A Programmer's Dream

Turning off ASP.NET LOGIN RETURN URL ability

Posted by Stephen Wrighton on 27 Aug 2008

A standard part of the way that the LOGIN controls work in .NET is that they append the RETURN URL to the query string, and when you successfully log into the application, they drop you back right where you were.

Which makes sense if you're knee deep in an application when you lose your authentication ticket for some reason.

But, what happens when you don't want that behavior. How do you make it where the application always sends you to the default page regardless of where the user had been.

Fun, eh?

Basically, what must occur is that you'll need to handle an event from the LOGIN control, called LOGGEDIN. When handling this event, it then becomes a simple matter of redirecting the user to the default page of the website. What's produced looks like this:

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
Response.Redirect("./")
End Sub

Simplicity in action, once you catch on.

Tweet me @kidananubix if you like this post.

Tweet