我提供HTTP Web服务,我的一个用户在Windows 2003机器上使用C#WebClient类从我的网站检索数据.我的用户说WebClient正在创建许多浏览器实例,需要关闭.如何在创建浏览器后关闭浏览器?
他的代码:
Byte[] requestedHTML;
WebClient client = new WebClient();
requestedHTML = client.DownloadData("http://abcabc.com/abc");
UTF8Encoding objUTF8 = new UTF8Encoding();
string returnMessage = objUTF8.GetString(requestedHTML);
Run Code Online (Sandbox Code Playgroud)
ps道歉,如果这听起来很业余,我对C#很新.
WebClient 不使用浏览器 - 它只是底层协议的包装器.你应该添加一个using,但这与"许多浏览器实例"无关:
using(WebClient client = new WebClient())
{
return client.DownloadString("http://abcabc.com/abc");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3729 次 |
| 最近记录: |