R
Rayc
I have a .NET login page that works fine locally but when
I upload to my web host provider the login page keeps
reappearing. When I click the login button, the login
page reappears asking to login again.
Here's the code behind my login_Click button:
clsSecurity oSec = new clsSecurity();
oSec.sUserName = txtUserName.Text;
oSec.sPassword = txtPassword.Text;
if (oSec.ValidUser() == true)
{
Session["UserID"] = oSec.iUserID.ToString();
Session["UserName"] = oSec.sUserName.ToString();
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1,txtUserName.Text,
DateTime.Now, DateTime.Now.AddMinutes(30), false, "your
custom data",FormsAuthentication.FormsCookiePath);
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName,
cookiestr);
ck.Expires=tkt.Expiration;
Response.Cookies.Add(ck);
string strRedirect;
lblMessage.Text = "UserID=" + Convert.ToString(Session
["UserID"]);
strRedirect = Request["ReturnUrl"];
if (strRedirect==null){
strRedirect = "Default.aspx";
Response.Redirect(strRedirect, true);
}
else
lblMessage.Text = "Invalid User Account.";
I upload to my web host provider the login page keeps
reappearing. When I click the login button, the login
page reappears asking to login again.
Here's the code behind my login_Click button:
clsSecurity oSec = new clsSecurity();
oSec.sUserName = txtUserName.Text;
oSec.sPassword = txtPassword.Text;
if (oSec.ValidUser() == true)
{
Session["UserID"] = oSec.iUserID.ToString();
Session["UserName"] = oSec.sUserName.ToString();
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1,txtUserName.Text,
DateTime.Now, DateTime.Now.AddMinutes(30), false, "your
custom data",FormsAuthentication.FormsCookiePath);
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName,
cookiestr);
ck.Expires=tkt.Expiration;
Response.Cookies.Add(ck);
string strRedirect;
lblMessage.Text = "UserID=" + Convert.ToString(Session
["UserID"]);
strRedirect = Request["ReturnUrl"];
if (strRedirect==null){
strRedirect = "Default.aspx";
Response.Redirect(strRedirect, true);
}
else
lblMessage.Text = "Invalid User Account.";