ashx 方法模板
int count = 0; this.page = DTRequest.GetQueryInt("page", 1); //查询字符串拼接 string searchparams = DTRequest.GetQueryString("jsonstring"); fooddetail model = jss.Deserialize<fooddetail>(searchparams); StringBuilder searchsql = new StringBuilder(); //判断名字是否为空 if (!string.IsNullOrEmpty(model.dishesName)) { searchsql.Append(" and dishesName like '%" + model.dishesName + "%'"); } BLL.restaurant bll = new BLL.restaurant(); try { var dt = bll.GetList(10, 1, "dishesId>0" + searchsql.ToString(), "sort_id asc,add_time desc,dishesId desc", out count).Tables[0]; string strjson = Dtb2Json(dt); context.Response.Write("{\"retcode\": 1,\"retmsg\": \"Success\", \"foodlist\":" + strjson + "}"); } catch (Exception e) { context.Response.Write("{\"retcode\": 2,\"retmsg\": \"" + e.Message + "\"}"); } finally { context.Response.End(); }