WebResponse response;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Timeout = 20000;
response = request.GetResponse();
request = (HttpWebRequest)WebRequest.Create(url2);
response = request.GetResponse();
}
catch(Exception ex)
{
//do something
}
finally
{
}
应该在哪里调用response.Close()?何时调用WebResponse.Close()
每个GetResponse()在尝试?
最后一次GetResponse()在try - once?
- 在finally块?
但是,如果他将response.Close()放在最后,他会得到'使用未分配的变量'错误。 – UpTheCreek 2011-04-29 21:08:51