登陆代码求指点!!!
<appSettings>
<add key="user" value="admin,123456|123,11111111"></add>
</appSettings> cs:
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string loginid = this.txtlogin.Value;
string pass = this.txtpass.Value;
if (this.txtvalidae.Value.ToLower().Equals(Session["post_validate_code"].ToString().ToLower()))
{
string valid = loginid + pass;
try
{
string users = ConfigurationManager.AppSettings["user"];
Hashtable h = new Hashtable();
foreach (string s in users.Split('|'))
{
h.Add(s.Split(',')[0], s.Split(',')[1]);
}
if (h.Contains(loginid))
{
if (h[loginid].ToString() == pass)
{
this.labshowerror.Text = "登录成功!";
FormsAuthentication.SetAuthCookie(loginid, true);
Session["UserInfo"] = loginid;
Response.Redirect("admin/index.aspx");
}
else
this.labshowerror.Text = "用户名或密码错误!";
}
else
this.labshowerror.Text = "用户名或密码错误!";
}
catch
{
this.labshowerror.Text = "用户名或密码错误!";
}
//this.labshowvalidate.Text = "";
}
}
}
点击btnLogin没反应~
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string loginid = this.txtlogin.Value;
string pass = this.txtpass.Value;
if (this.txtvalidae.Value.ToLower().Equals(Session["post_validate_code"].ToString().ToLower()))
{
string valid = loginid + pass;
try
{
string users = ConfigurationManager.AppSettings["user"];
Hashtable h = new Hashtable();
foreach (string s in users.Split('|'))
{
h.Add(s.Split(',')[0], s.Split(',')[1]);
}
if (h.Contains(loginid))
{
if (h[loginid].ToString() == pass)
{
this.labshowerror.Text = "登录成功!";
FormsAuthentication.SetAuthCookie(loginid, true);
Session["UserInfo"] = loginid;
Response.Redirect("admin/index.aspx");
}
else
this.labshowerror.Text = "用户名或密码错误!";
}
else
this.labshowerror.Text = "用户名或密码错误!";
}
catch
{
this.labshowerror.Text = "用户名或密码错误!";
}
//this.labshowvalidate.Text = "";
}
}
}