protected void Button2_Click(object sender, EventArgs e) { var user = db.One((User u) => u.UserId == CheckValid()); if (user != null) { var path = Path.Combine("../../", Image1.ImageUrl); var dictinary = new Dictionary <string, object> { { "ImgUrl", path } }; db.Update <User>(user.UserId, dictinary); var box = new Iamgbox { ActionTime = DateTime.Now, BoxName = user.UserName, ImgUrl = path, IsValid = true, //默认是正规合适的图片 不合适在检举 PraiseCount = 0, Remark = "我的头像", UserId = user.UserId, VisitCount = 0, }; db.Add(box); var state = new State { UserId = user.UserId, ActionTime = box.ActionTime, Content = "我刚刚更换了头像:<br/><div class='imgtigger'><img src='" + path + "' /></div>", StateType = StateType.Image.ToString(), }; db.Add(state); } Response.Redirect("/User/Index"); }