我用VS.NET自带的登陆控件,但是我想记录登陆信息(日志),怎么做?

解决方案 »

  1.   

    Enterprise Library 2006有个专门对日志管理的程序块
      

  2.   

    可以在MSDN帮助看到么?
    能否提供相应的资料么?
      

  3.   

    在登录按钮的处理里面,只要用户登录成功,则向数据库里面写入一条登录信息!登录信息的具体内容可以由你自己决定,可以包含UserNM、UserID、登录时间、登录IP等等!
      

  4.   

    private void LOGIN1_Click(object sender, System.EventArgs e)
    {
    string[] Access=LoginAccess(UserName.Text.Trim(),UserPwd.Text.Trim()); if(Access[1]!="AdminAccess")
    {
    string strusername=UserName.Text.Trim();
    string strvalue="登陆失败";
    string strresult=Access[1];
    string[] NewLogin=new string[]
    {
       strusername,
       DateTime.Now.ToString(),
       strvalue,
       Request.UserHostAddress.ToString(),
       strresult }; Insert_LoginInfo(NewLogin);   
    Response.Write("<script language=javascript>");
    Response.Write("window.alert('");
    Response.Write(Access[1]);
    Response.Write("');");
    Response.Write("</script>");
    }
    else
    {
        DataTable DT1=List_Admin(UserName.Text);
    Response.Cookies["user"].Value=UserName.Text.Trim();
    Response.Cookies["role"].Value=DT1.Rows[0]["AdminRole"].ToString();
    string strusername=UserName.Text.Trim();
    string strvalue="登陆成功";
    string strresult=Access[1];
    string[] NewLogin=new string[]
    {
    strusername,
    DateTime.Now.ToString(),
    strvalue,
    Request.UserHostAddress.ToString(),
    strresult }; Insert_LoginInfo(NewLogin); Session["AdminID"]=Access[0].ToString();
    string tt="test = window.open('"+Request.ApplicationPath+"/index.htm"+"'"
    +",'','toolbar=no,menubar=no,titlebar=yes,directories=no,resizable=yes,status=yes,fullscreen=no,top=0;left=0,width=900,height=700');";
    Response.Write("<script language=javascript>");
    Response.Write(tt);
    Response.Write("test.moveTo(0,0);");
    Response.Write("test.resizeTo(screen.availWidth,screen.availHeight);");
    Response.Write("window.opener=null;");
    Response.Write("window.close();");
    Response.Write("</script>");
    }

    }
      

  5.   

    接分拉~~~~~~~~~~~
    其中插入日志的函数为
    private void Insert_LoginInfo(string[] NewLogin)
    {
    SqlCommand Comm=new SqlCommand("insert into LoginInfo(LoginName,LoginTime,LoginValue,LoginIP,LoginResult)values('"+NewLogin[0]+"','"+NewLogin[1]+"','"+NewLogin[2]+"','"+NewLogin[3]+"','"+NewLogin[4]+"')",Conn);
    Conn.Open();
    Comm.ExecuteNonQuery();
    Conn.Close();
    }
    -------------------------------
    也是刚写的,没分层
    自己都有点看不清楚