public void addSupply(HttpContext context) { context.Response.ContentType = "text/plain"; Supply supply = new Supply(); supply.SupplyName = context.Request["Name"]; supply.SupplyDesc = context.Request["Desc"]; supply.SupplyCategory.Id = Convert.ToInt32(context.Request["CategoryId"]); supply.User.Id = Convert.ToInt32(context.Session["userId"]); //supply.User.Id = 1;//暂时 Dictionary <String, Object> dictionary = new Dictionary <string, object>(); int id = supplyService.addSupply(supply); if (id > 0) { dictionary.Add("Id", id); dictionary.Add("success", "true"); } else { dictionary.Add("success", "false"); } context.Response.Write(JsonUtil.toJson(dictionary).ToString()); }