Walt Ritscher: Thinking about code

Thoughts about .Net - Thoughts about code

  Home :: Contact :: Syndication  :: Login
  171 Posts :: 0 Stories :: 80 Comments :: 23 Trackbacks

Archives

Post Categories

Image Galleries

About Me

Interesting Blogs

My other blogs

Resources

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

posted on Thursday, May 18, 2006 1:56 PM

Feedback

No comments posted yet.
Comments Closed! Due to the spam creeps.
If you want to comment, use the contact page and send me an email and the URL of this Post.
Title  
Name  
Url

Comments   
Enter the code you see: