// url 网路图片
// 例:https://lmg.jj20.com/up/allimg/4k/s/02/2109242332225H9-0-lp.jpg
public bool GetImageIsExists(string url)
{
string message = "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(url));
ServicePointManager.Expect100Continue = false;
try
{
((HttpWebResponse)request.GetResponse()).Close();
}
catch (WebException exception)
{
if (exception.Status != WebExceptionStatus.ProtocolError)
{
message = "";
}
if (exception.Message.IndexOf("500 ") > 0)
{
message = "服务器内部错误,无法完成请求,请联系管理员!";
return false;
}
if (exception.Message.IndexOf("401 ") > 0)
{
message = "需要身份认证,你没有权限!";
return false;
}
if (exception.Message.IndexOf("404") &g
.net后台判断服务器(http/https开头)图片是否存在
最新推荐文章于 2022-10-26 10:18:57 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)