首页 > 解决方案 > WebClient.DownloadData 返回状态码 444

问题描述

我正在尝试从 url 下载图像,但出现“远程服务器返回错误:(444)无响应”之类的异常。

这是下载图像的代码

string url = "https://listing-images.homejunction.com/bright/304545918990/photo_20.jpg";
System.Threading.Thread.Sleep(1000);
using (WebClient wc = new WebClient())
{
    byte[] byteUrl = wc.DownloadData(url);
    Image orgImg = Bitmap.FromStream(new MemoryStream(byteUrl));
    Bitmap bmpImage = new Bitmap(orgImg);
    Bitmap bmpCrop = bmpImage.Clone(new Rectangle(0, 0, orgImg.Width, orgImg.Height - CropSize), bmpImage.PixelFormat);
    MemoryStream memoryStream = new MemoryStream();
    bmpCrop.Save(memoryStream, orgImg.RawFormat);
    return memoryStream;
}

标签: c#webclientimagedownload

解决方案


推荐阅读