如何判断某个.asmx链接有效?????

xb12369 2012-05-04 05:19:40
我是用这个:

try
{

System.Net.WebRequest myRequest = System.Net.WebRequest.Create(

"http://192.168.0.6/rootserver/DirService.asmx ");


System.Net.WebResponse myResponse = myRequest.GetResponse();


return "ok ";
}
catch (Exception ex)
{
return ex.Message.ToString();
}


如果链接不通,会跳到catch里去,而且会等半天!!!

有没有更好的办法,判断???
...全文
158 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xb12369 2012-05-06
  • 打赏
  • 举报
回复
[size=48px]继续等大神的帮助。[/size]
xb12369 2012-05-06
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

你可以设置
myRequest.Timeout = //很短的时间
myRequest.Proxy = null;

好像没有更好的方法
[/Quote]

5楼,你好,这个方法好像也不行额!!!
你看下是不是这样用:


public string RetAsmx()
{
try
{

System.Net.WebRequest myRequest = System.Net.WebRequest.Create("http://192.168.105.10/hotelwebsrv/hotelwebsrv.asmx");
myRequest.Timeout = 100;
myRequest.Proxy = null;


System.Net.WebResponse myResponse = myRequest.GetResponse();


return "ok ";
}
catch (Exception ex)
{
return ex.Message.ToString();
}

}


大概还是耗时16―18秒,我现在面临的数据大概有1600条左右,这个时间太慢了,所以我想快一点的方法,来压缩一下这个时间!!!

继续等待ing
孟子E章 2012-05-04
  • 打赏
  • 举报
回复
你可以设置
myRequest.Timeout = //很短的时间
myRequest.Proxy = null;

好像没有更好的方法

xb12369 2012-05-04
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
可以参见
http://dotnet.aspx.cc/file/Delect-Url-Exists.aspx

使用HEAD
[/Quote]

使用HEAD跟我贴出来的一样,只要.asmx无效,就会跳转到catch里面去,并且很慢很慢,我不要这种,还有木有更好的,求想详细,在线等!!!
xb12369 2012-05-04
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
那就搞成异步的
[/Quote]

跪求详细!!!!在线等!!!
孟子E章 2012-05-04
  • 打赏
  • 举报
回复
可以参见
http://dotnet.aspx.cc/file/Delect-Url-Exists.aspx

使用HEAD
bdmh 2012-05-04
  • 打赏
  • 举报
回复
那就搞成异步的

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧