Please Enter Again
can not redirect page
I have my login page is working, I can connect to the db server and check user,
Looks like this.
int i = database.DBStore1.ReturnDB("select * from users where username='" + Username.Text.Trim() + "' and Password='" + Password.Text.Trim() + "'");
if (i > 0)
{
Session.Add("username", Username.Text);
msglbl.Text = "Successfully Login ";
Response.Redirect("default.aspx");
}
else
{
msglbl.Text = "Invalid user name or Password!
Please Enter Again ";
}
}
Above code works, except I can not direct to default.aspx (the url shows as)
http://localhost:2253/test/Login.aspx?ReturnUrl=%2ftest%2fdefault.aspx
any idea why I can't see default.aspx
Thank you
Please Enter Again
Niradhip ChakrabortyPosted Aug 4, 2009, 5:55 AM
If I understood your problem,as per your code if login is successful you are redirecting to default page and instead of default.aspx you are redirecting to http://localhost:2253/test/Login.aspx?ReturnUrl=%2ftest%2fdefault.aspx this page. This means somewhere in default.aspx you are redirecting to Login.aspx page.
I don't think session will come into picture here because as you mentioned you don't have any pagebehind code in default.aspx page. Check out the head tag.
Are you using something like this in head tag of html page?
"test/Login.aspx?ReturnUrl=%2ftest%2fdefault.aspx "/>
lindaPosted Aug 3, 2009, 11:26 AM
Niradhip ChakrabortyPosted Aug 3, 2009, 10:31 AM
Check Out the code inside default.aspx. You need to open the .cs file of default.aspx and check the code in pageload. You may redirecting to Login page automatically from default.aspx page.