我想从服务器下载图像。当图像不存在时,我想显示我的默认图像。
这是我的代码:
string url = "http://www......d_common_conference" + "/" + c.id_common_conference + "-MDC.jpg";
try {
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "HEAD";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
string status = Response.StatusCode.ToString();
img.ImageUrl = url;
}
catch (Exception excep) {
img.ImageUrl = "images/silhouete.jpg";
string msg = excep.Message;
}
它工作得很好,但直到第 24 个循环,没有响应,没有抛出异常,我的程序变得卡住了。
我怎样才能解决这个问题?