Tuesday, August 26, 2008

Turning off ASP.NET LOGIN RETURN URL ability

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
End Sub

Simplicity in action, once you catch on.


matejkralik said...

Good and rather simple solution that helped me. :)

Stephen Wrighton said...

That's great to hear :D

Blog Widget by LinkWithin