Hi there is a problem in my login page.
The scenario is,
For example i go to http://www.mydomain.com/admin/ its redirecting me to the login page with ReturnURL parameter like this. http://www.mydomain.com/login.aspx?ReturnURL=%2fAdmin%2f.
I am logging in with admin account and everything works fine.
But if i go to Login.aspx directly which means there isn’t ReturnURL QueryString field.
I log in with same admin account but when i try to go http://www.mydomain.com/admin/ after i logged in its redirecting me back to the login page.
I’m doing navigates like this. What i am missing?
//The code block that is logging in admin.
//check if there is a ReturnURL
if (QueryStringTool.IsExistAndNotNull("ReturnURL"))
{
Session["UserType"] = UserTypes.UserType.Admin;
Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Text.Trim(), false));
}
//ReturnURL doesn't exists.
else
{
FormsAuthentication.SetAuthCookie(txtUserName.Text, cbUserRememberMe.Checked);
Response.Redirect("/Admin/Default.aspx");
}
Now try this. Replace your code
with this one
This will work for your whole code. Redirects an authenticated user back to the originally requested URL or the default URL.
Check on
DefaultpageLoadeventSession["UserType"]if user isAdminthen redirect him to admin page