string rXml = string.Empty;
HttpWebRequest myHttpWebRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
myHttpWebRequest.KeepAlive = false;
myHttpWebRequest.AllowAutoRedirect = false;
myHttpWebRequest.UserAgent = "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
myHttpWebRequest.Timeout = 10000;
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
using (HttpWebResponse res = (HttpWebResponse)myHttpWebRequest.GetResponse())
{
if (res.StatusCode == HttpStatusCode.OK || res.StatusCode == HttpStatusCode.PartialContent)//返回为200或206
{
string dd = res.ContentEncoding;
System.IO.Stream strem = res.GetResponseStream();
System.IO.StreamReader r = new System.IO.StreamReader(strem);
rXml = r.ReadToEnd();
}
}
Response.Write(rXml);