As you are using form authentication and want to redirect to custom page so you need to do it like below.
micah says:
userName = dt.Rows[0][
"UserName"
].ToString();
location = dt.Rows[0][
"Location"
].ToString();
if
(!
string
.IsNullOrEmpty(location) && location !=
"-1"
&& location !=
"-2"
)
{
Session[
"userName"
] = userName;
switch
(location)
{
case
"state1"
:
Response.Redirect(
"~/state1/"
+ location +
"Page.aspx"
);
break
;
case
"state2"
:
Response.Redirect(
"~/state2/"
+ location +
"Page.aspx"
);
break
;
case
"state3"
:
Response.Redirect(
"~/state3/"
+ location +
"Page.aspx"
);
break
;
}
}
else
{
switch
(location)
{
case
"-1"
:
LoginINNOVATION.FailureText =
"Username or password not correct."
;
break
;
case
"-2"
:
LoginINNOVATION.FailureText =
"Account has not been activated."
;
break
;
}
}
Replace the above code with the below.
userName = dt.Rows[0]["UserName"].ToString();
location = dt.Rows[0]["Location"].ToString();
if (!string.IsNullOrEmpty(location) && location != "-1" && location != "-2")
{
Session["userName"] = userName;
switch (location)
{
case "Texas":
// Add this line of code.
FormsAuthentication.SetAuthCookie(LoginINNOVATION.UserName, LoginINNOVATION.RememberMeSet);
Response.Redirect("~/Texas/" + location + "Page.aspx");
break;
case "Washinton":
// Add this line of code.
FormsAuthentication.SetAuthCookie(LoginINNOVATION.UserName, LoginINNOVATION.RememberMeSet);
Response.Redirect("~/Washinton/" + location + "Page.aspx");
break;
case "Maryland":
// Add this line of code.
FormsAuthentication.SetAuthCookie(LoginINNOVATION.UserName, LoginINNOVATION.RememberMeSet);
Response.Redirect("~/Maryland/" + location + "Page.aspx");
break;
}
}
else
{
switch (location)
{
case "-1":
LoginINNOVATION.FailureText = "Username or password not correct.";
break;
case "-2":
LoginINNOVATION.FailureText = "Account has not been activated.";
break;
}
}