public void getRequirementDescImg(HttpContext context) { List <RequirementImg> list = requirementService.getRequirementDescImg(Convert.ToInt32(context.Request["Id"])); StringBuilder sb = new StringBuilder(); Dictionary <String, Object> dictionary = new Dictionary <String, Object>(); string imgPath = "defaultImg.jpg"; sb.Append("["); int i = 1; foreach (RequirementImg requirementImg in list) { if (requirementImg.ImgPath != null) { imgPath = System.IO.Path.GetFileName(requirementImg.ImgPath); } dictionary.Add("DescImg", imgPath); sb.Append(JsonUtil.toJson(dictionary)); if (i < list.Count) { sb.Append(","); } dictionary.Clear(); i++; } sb.Append("]"); context.Response.Write(sb.ToString()); }