各位大牛请进,本人小白,帮忙看段代码,谢谢了!!!!
protected void btnLogin_Click (object sender, ImageClickEventArgs e)
{
try
{
SqlParameter parameter1 = new SqlParameter("@Uid\uFFFD", SqlDbType.VarChar, 0x20);
parameter1.Value = this.txtUid.Text.Trim();
using(SqlDataReader reader1 = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["SqlConStr\uFFFD"].ConnectionString, CommandType.Text, "select Pwd from T_User where Uid = @Uid\uFFFD", new SqlParameter[]{parameter1}))
{
if (reader1.Read() && (Encoding.ASCII.GetString(new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(this.txtPwd.Text.Trim()))) == reader1["Pwd\uFFFD"].ToString()))
{
SqlParameter[] parameterArray1 = new SqlParameter[]{new SqlParameter("@LastLoginDate\uFFFD", SqlDbType.DateTime), new SqlParameter("@LastLoginIP\uFFFD", SqlDbType.VarChar, 15), new SqlParameter("@Uid\uFFFD", SqlDbType.VarChar, 0x20)};
parameterArray1[0].Value = DateTime.Now;
parameterArray1[1].Value = base.Request.UserHostAddress;
parameterArray1[2].Value = this.txtUid.Text.Trim();
SqlHelper.ExecuteNonQuery(ConfigurationManager.ConnectionStrings["SqlConStr\uFFFD"].ConnectionString, CommandType.Text, "update T_User set LastLoginDate = @LastLoginDate, LastLoginIP = @LastLoginIP where Uid = @Uid\uFFFD", parameterArray1);
base.Response.Cookies["UserName\uFFFD"].Value = this.txtUid.Text.Trim();
if (this.ddlLoginState.SelectedIndex != 0)
{
base.Response.Cookies["UserName\uFFFD"].Value = this.txtUid.Text.Trim();
base.Response.Cookies["UserName\uFFFD"].Expires = DateTime.Now.AddDays((double) int.Parse(this.ddlLoginState.SelectedValue));
}
this.Session["UserName\uFFFD"] = this.txtUid.Text.Trim();
this.openWindow();
}
else
{
this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msgbox\uFFFD", "<script>window.alert('\u7528\u6237\u540D\u6216\u5BC6\u7801\u4E0D\u6B63\u786E\uFF01');document.getElementById('txtPwd').focus();</script>\uFFFD");
}
}
}
catch (Exception exception1)
{
File.AppendAllText(base.Server.MapPath("log\\error\uFFFD" + DateTime.Today.ToString("yyyyMMdd\uFFFD") + ".log\uFFFD"), string.Concat(new string[]{DateTime.Now.ToString("HH:mm\uFFFD"), " \u9875\u9762\uFF1A\uFFFD", base.Request.Url.ToString(), "\uFF1B\u4E8B\u4EF6\uFF1AbtnLogin_Click\uFF1B\u9519\u8BEF\u4FE1\u606F\uFF1A\uFFFD", exception1.Message, "\r\n\uFFFD"}));
}
} C#语言
[解决办法]
这段代码的意思是:根据用户名到数据库中查询,如果有这个账号则记录当前登录的最后更新时间。记录界面选择的Cookie保留时间。并没有无权登录的代码。
[解决办法]
是发布的时候预编译过的。已经把aspx.cs编译成DLL了
[解决办法]