如何使用vb.net在asp.net中ping IP地址? [英] How to ping IP Address in asp.net Using vb.net ?

查看:70
本文介绍了如何使用vb.net在asp.net中ping IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai

如何使用vb.net在asp.net中ping ip地址,我在网格视图中加载了20多个ip地址,如果ip地址是ping它在网格中显示连接图标查看,如果不是它显示断开连接的图标。我已经完成,但如果超过20个IP地址,太长时间太慢,这里我把代码更改为基于压缩地址的图像图标。

Hai
How to ping ip address in asp.net using vb.net,i have more than 20 ip address it load in grid view,if ip address is ping it show connected icon in grid view and if not it show disconnected icon.I have done but pining time is too slow if more than 20 ip address,here i put code for change the image icon based on pining address.

Protected Sub gvDevice_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvDevice.RowDataBound
     If (e.Row.RowType = DataControlRowType.DataRow) Then

         Dim imgStatuss As Image = e.Row.FindControl("imgStatus")


         Dim status As String = DataBinder.Eval(e.Row.DataItem, "IPAddress")

         Dim ping As Ping = New Ping()
         Dim pingreply As PingReply = ping.Send(status)'---->tatus is IP Address
         Dim reply As String = pingreply.Status

         If (reply = 0) Then'---> if reply is 0 it can ping,if other than 0 can not ping ip address
             imgStatuss.ImageUrl = "~/images/icon_Status-Connected.png"
         Else
             imgStatuss.ImageUrl = "~/images/icon_Status-Disconnected.png"
         End If
     End If
 End Sub





以上代码效果很好,但需要很长时间在gridview中加载的时间,请回复如何快速ping并在gridview中加载。



问候

Aravind



The above code is works well,but it take long time to load in gridview,pls reply how ping fastly and load in gridview.

Regards
Aravind

推荐答案

你无法提高t他只是扮演客户的角度。你无能为力。



-SA
You cannot improve the ping timing as you merely act as a client. You cannot do much about it.

—SA


这篇关于如何使用vb.net在asp.net中ping IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆