Login Securiuty

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.";
 
T

Tian Min Huang

Hello,

Thanks for your post. I'd like to share the following information with you:

1. I did not find any obvious problem in your code. I recommend you debug
the page and check the following line especially:

a. if (oSec.ValidUser() == true)?
b. if (strRedirect==null)?

Please refer to the following MSDN article on "ASP Remote Debugging Setup"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/htm
l/vxtskaspremotedebuggingsetup.asp

2. The KB article 301240 provides the same funcationality, please refer to
it or you may even follow its steps and see if it works on your side.
HOW TO: Implement Forms-Based Authentication in Your ASP.NET Application by
Using C# .NET
http://support.microsoft.com/?id=301240

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top