public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //获取用户要删除的BookID int Bookid = Convert.ToInt32(context.Request["Bookid"]); BooksBll Bll = new BooksBll(); bool falg = Bll.Delete(Bookid); if (falg) { context.Response.Write("ok"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string filepath = Server.MapPath("/BookCovers"); BooksBll bbl = new BooksBll(); var list = bbl.GetModelList(""); int i = 0; foreach (var item in list) { bool flag = File.Exists(filepath + "/" + item.ISBN + ".jpg"); if (!flag) { bbl.Delete(item.Id); i++; } } Response.Write("一共删除了" + i); } }