M
Matt Owens
I have a login page which does not redirect the user once
the code has been executed, see below. Whats strange is
it works perfectly on my localhost when debugging,
however it fails to redirect when depolyed to a remote
server. Am I missing any IIS settings or anything? The
login page just reloads once the login button has been
clicked.
Code for the login button:
private void _btnLogin_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (IsValidUser(txtUserName.Text,
txtPassword.Text)) //interacts with the database. This
method is fine
{
if(FormsAuthentication.GetRedirectUrl
(txtUserName.Text,false)=="/appliedbioscience/index.aspx")
{
FormsAuthentication.SetAuthCookie
(txtUserName.Text,false);
Response.Redirect
("http://www.appliedbioscience.co.uk/appliedbioscience/ind
ex.aspx",false); //fails here
}
else if
((FormsAuthentication.GetRedirectUrl
(txtUserName.Text,false).ToUpper().IndexOf("ADMIN") != -
1) && (string)Session["Role"]!="admin")
phMsg.Controls.Add(new
LiteralControl("<font color=red>ERROR: You do not have
the necessary privellages to administrate this
site</font>"));
else
FormsAuthentication.RedirectFromLoginPage
(txtUserName.Text,false); //fails here too
}
else
{
phMsg.Controls.Add(new LiteralControl
("<font color=red>ERROR: Invalid Username /
Password</font>"));
}
}
Thanks,
Matt
the code has been executed, see below. Whats strange is
it works perfectly on my localhost when debugging,
however it fails to redirect when depolyed to a remote
server. Am I missing any IIS settings or anything? The
login page just reloads once the login button has been
clicked.
Code for the login button:
private void _btnLogin_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (IsValidUser(txtUserName.Text,
txtPassword.Text)) //interacts with the database. This
method is fine
{
if(FormsAuthentication.GetRedirectUrl
(txtUserName.Text,false)=="/appliedbioscience/index.aspx")
{
FormsAuthentication.SetAuthCookie
(txtUserName.Text,false);
Response.Redirect
("http://www.appliedbioscience.co.uk/appliedbioscience/ind
ex.aspx",false); //fails here
}
else if
((FormsAuthentication.GetRedirectUrl
(txtUserName.Text,false).ToUpper().IndexOf("ADMIN") != -
1) && (string)Session["Role"]!="admin")
phMsg.Controls.Add(new
LiteralControl("<font color=red>ERROR: You do not have
the necessary privellages to administrate this
site</font>"));
else
FormsAuthentication.RedirectFromLoginPage
(txtUserName.Text,false); //fails here too
}
else
{
phMsg.Controls.Add(new LiteralControl
("<font color=red>ERROR: Invalid Username /
Password</font>"));
}
}
Thanks,
Matt