Thursday, February 3, 2011

Login Control Never Redirects to Index or Default page

Working with login control in asp.net provides convenient way to apply secured user API with less programming. Since login control is part of .net framework,such classes are provided such as membership, forms authentication and etc..

One weird error i encountered is that, it does not redirect to my index page once login has been successful. I implemented my own validation function to check if a user exists in the database. If the method returns true, redirect to index page. See code below. But the fact is, it does not redirect.
Code:
  if (CheckUserInMyDB(Login1.UserName, Login1.Password))  
  {  
     e.Authenticated = true;  
     Login1.Visible = false;  
     Response.Redirect("Index.aspx");  
  }  
  else  
  {  
     e.Authenticated = false;  
  }
So the solution i found in forums.asp.net was to transfer the Response.Redirect to Logged in method of the login control.

0 comments:

Post a Comment