服务器上,发布了一个小网站,有登录功能,能正常登录,其他功能也一切正常,里面有session["userinfo"]。
但过一段时间后,在操作过程中,突然感觉session清空了,需要根据session动态加载的一些菜单都不见了,点重新登录按钮,跳转到login.aspx,再登录时,系统提示“用户名密码错误!!!”
在IIS把网站重启了,还是登录不了,最后把IIS重启了,系统正常了,可以登录了,这会是什么原因呀。protected void Button1_Click1(object sender, EventArgs e)
    {
        try
        {
            string username = txt_userid.Text;
            string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txt_pwd.Text.ToString().Trim(), "MD5");            DataAdmin lm = new DataAdmin();
            string sql = "select * from vw_user_info where User_loginid ='" + txt_userid.Text + "' and User_pwd='" + pwd + "'";
            DataTable dt = lm.QueryInfo(sql);
            int i = dt.Rows.Count;
            if (i == 1)
            {
                //string aaa = dt.Rows[0]["user_id"].ToString();
                //string bbb = dt.Rows[0]["depart_name"].ToString();                                 Session["userid"] = dt.Rows[0]["user_id"].ToString();
                Session["username"] = dt.Rows[0]["user_name"].ToString();
                Session["userdepartname"] = dt.Rows[0]["depart_name"].ToString();
                Session["userrolename"] = dt.Rows[0]["Role_name"].ToString();
                Response.Redirect("index.aspx");    //跳转到主页面
            }
            else
            {
                Response.Write("<script>alert('用户名称或者密码输入错误,请重新输入!');window.location.href='Login.aspx';</script>");
            }
        }
        catch (Exception ex)
        {
            Console.Write(ex.Message);
        }
        finally
        {        }