日期:2014-05-17 浏览次数:20509 次
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.KeepAlive = false; req.Method = "POST"; req.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; req.Credentials = CredentialCache.DefaultCredentials; req.ContentType = "application/x-form-www-urlencoded"; Encoding encode = new UTF8Encoding(); byte[] b = encode.GetBytes(string.Format("Content={0}&Type={1}&StartDate={2}&EndDate={3}", content, columnname.ToLower() == "macaddress" ? 1 : 0, DateTime.Now.AddDays(-1).Date.ToString("yyyy-MM-dd 00:00:00"), DateTime.Now.Date.ToString("yyyy-MM-dd 00:00:00"))); req.ContentLength = b.Length; using (Stream stream = req.GetRequestStream()) { stream.Write(b, 0, b.Length); } WebResponse res = req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream(), encode); string result = sr.ReadToEnd(); res.Close(); sr.Close();