这是我的代码,我在其中使用 HttpWebRequest 请求 URL 并从 HttpWebResponse 获取响应。但是 httpwebresponse 对象会抛出一个异常,即 Internal Server Error!
url="http://www.google.com/"
Uri urlCheck = new Uri(url);
request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 5000000;
response = (HttpWebResponse)request.GetResponse(); //Here Getting The Exception..
receiveStream = response.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
strmRead = new StreamReader(receiveStream, encode);
result = strmRead.ReadToEnd();