protected void Page_Load(object sender, EventArgs e) { JToken scrts = HttpContext.Current.Cache["scrts"] as JToken; if (scrts == null) { string url = ConfigurationManager.AppSettings["url"]; xtelsWebClient wc = new xtelsWebClient(); JObject r = wc.JsonWebQuery(url); scrts = r[ConfigurationManager.AppSettings["scrts"]]; HttpContext.Current.Cache["scrts"] = scrts; } scrt scr; List<scrt> scrList = new List<scrt>(); foreach (JToken sc in scrts) { scr = new scrt(); scr.cover = Convert.ToString(sc["cover"]); scr.name = Convert.ToString(sc["name"]); scr.id = Convert.ToString(sc["id"]); scr.contact = Convert.ToString(sc["contact"]); scrList.Add(scr); } rptResultados.DataSource = scrList; rptResultados.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string req_id = Request.Params["id"]; if(req_id !=null && !IsPostBack){ JObject scrt_data = HttpContext.Current.Cache["scrt" + req_id] as JObject; if (scrt_data == null) { xtelsWebClient wc = new xtelsWebClient(); scrt_data = wc.JsonWebQuery(ConfigurationManager.AppSettings["api_prefix"] + req_id + ".json"); HttpContext.Current.Cache["scrt" + req_id] = scrt_data; } }else if(!IsPostBack){ Response.Redirect("index.aspx"); } }