asp.net(c#)判断远程图片是否存在_asp.net教程-查字典教程网
asp.net(c#)判断远程图片是否存在
asp.net(c#)判断远程图片是否存在
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:privateintGetUrlError(stringcurl){intnum=200;if(this.method==...

复制代码 代码如下:

private int GetUrlError(string curl)

{

int num = 200;

if(this.method==1)

{

HttpWebRequest request=(HttpWebRequest) WebRequest.Create(new Uri(curl));

ServicePointManager.Expect100Continue=false;

try

{

((HttpWebResponse)request.GetResponse()).Close();

}

catch(WebException exception)

{

if(exception.Status != WebExceptionStatus.ProtocolError)

{

return num;

}

if(exception.Message.IndexOf( "500 ")>0)

{

return 500;

}

if(exception.Message.IndexOf( "401 ")>0)

{

return 401;

}

if(exception.Message.IndexOf("404")>0)

{

num=404;

}

}

return num;

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新asp.net教程学习
    热门asp.net教程学习
    编程开发子分类