I fixed a bug this morning on our clients ASP.NET 2.0 website. The site uses the ASP.NET 2.0 Login control. If the user logged in with one account, logged out and attempted to login again they were not redirected to the destination page.
I coded the following in the Login control Authenticate event and it appears to solve the problem.
Protected Sub Login1_Authenticate _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) _
Handles Login1.Authenticate
‘ validation code here…
If e.Authenticated Then
If Request.QueryString("ReturnUrl") IsNot Nothing Then
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, False)
Else
FormsAuthentication.SetAuthCookie(Login1.UserName, False)
‘ we shouldn’t have to do this
‘ but I’m finding that the page doesn’t always redirect
Response.Redirect(Login1.DestinationPageUrl)
End If
End If