OpenRead url 给出异常:找不到路径的一部分

OpenRead url give exception: Could not find a part of the path

try
{    
    string url = "jquery.org/resources/members/ibm.png";
    using (WebClient client = new WebClient())
    {
        using (Stream stream = client.OpenRead(url))
        {
           //some login here
        }
    }
}
catch (Exception e)
{
  return false;
}

异常:“找不到路径的一部分 'C:\Windows\SysWOW64\inetsrv\jquery.org\resources\members\ibm.png'。

url 不包含 "http://" 或 "https://",它在 C 盘中找到,我如何从这个 url?[=12 执行 OpenRead 流=]

首先尝试添加方案 "http://"。在您的示例中,请求 http://jquery.org/resources/members/ibm.png 将收到 301 永久移动

WebClient 应该自动跟在响应中的 Location-header 之后,然后再发送到 https://jquery.org/resources/members/ibm.png.

此外,如果先前的 http 请求没有成功并且响应中没有 Location-header,您还可以在代码中添加一些错误处理并使用方案 https:// 手动执行另一个请求。