public void LogMaintenance() { Logs log = new Logs(); log.logtype = "用户访问"; log.logcontent = "用户访问"; log.logtime = DateTime.Now; log.loguser = ""; log.logip = IpSupport.GetClientIp(); log.logfree = IpSupport.GetAdrByIp(log.logip); db.Logs.Add(log); db.SaveChanges(); }
public ActionResult LoginCheck(LoginModel model, string returnUrl) { if (ModelState.IsValid && LoginCk(model.UserName, model.Password)) { Session.Add("username", model.UserName); Session.Add("password", model.Password); Logs log = new Logs(); log.logtype = "控制台登陆"; log.logcontent = "控制台登陆"; log.logtime = DateTime.Now; log.loguser = model.UserName; log.logip = IpSupport.GetClientIp(); db.Logs.Add(log); db.SaveChanges(); return(RedirectToAction("Index", "Console")); } // 如果我们进行到这一步时某个地方出错,则重新显示表单 ModelState.AddModelError("", "提供的用户名或密码不正确。"); return(View("Index", model)); }