1 private Dictionary<string, Object> GetLocation(string imei) 2 { 3 #region===代码=== 4 string serviceAddress = string.Format("http://localhost/api/car/getlastinfo?imei={0}&key=xxxxx",imei); 5 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serviceAddress); 6 req.Method = "get"; 7 req.KeepAlive = false; 8 var resp = new StreamReader(((HttpWebResponse)req.GetResponse()).GetResponseStream(), Encoding.GetEncoding("utf-8")); 9 string res = resp.ReadToEnd(); 10 resp.Close(); 11 Dictionary<string, Object> dic = null; 12 if (res != "") 13 { 14 dic = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res); 15 } 16 return dic; 17 #endregion===代码=== 18 }
解决:设置 req.KeepAlive = false;
走好选择的路,别选择好走的路