public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            List <Photoes>       result    = Photoes.GetData();
            int                  pageIndex = Convert.ToInt32(context.Request["page"]);
            var                  filtered  = result.Where(p => p.imgUrl >= pageIndex * 20 - 19 && p.imgUrl <= pageIndex * 20).ToList();
            JavaScriptSerializer ser       = new JavaScriptSerializer();
            string               jsonData  = ser.Serialize(filtered);

            context.Response.Write(jsonData);
        }
Exemple #2
0
        //模拟数据库有两百条数据
        public static List <Photoes> GetData()
        {
            List <Photoes> list = new List <Photoes>();
            Photoes        pic  = null;

            for (int i = 21; i <= 200; i++)
            {
                pic        = new Photoes();
                pic.imgUrl = i;
                pic.Name   = "Picture-" + i;
                list.Add(pic);
            }
            return(list);
        }