Get current computer name: System.net.dns.gethostname ()
Remove all IP address according to computer name: System.net.dns.resolve (computer name). AddressList or
System.net.dns.gethostbyname (computer name). AddressList Remove computer name from IP address
: System.net.dns.resolve (IP address). Hostname below we will use an example to see how to obtain
Take the IP address of this machine and get our host name.
<%@ page Language=vb debug=true%>
<script runat=server>
Sub Page_Load (ByVal sender As Object, ByVal e As EventArgs)
Lblmessage.text = "Your IP address:" _
& request.userhostaddress & "<br>" _
& "Your Host name:" _
& Request.userhostname & "<br>"
End Sub
</script>
<title>host and IP address</title>
<form runat= "Server" >
<asp Tutorial: Label
Id= "Lblmessage"
Font-size= "12pt"
Font-name= "Tahoma"
runat= "Server"
/>
</form>
</body>
Application examples
Add the following code to the Form_Load event:
Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim address () as System.Net.IPAddress
Dim i As Integer
Address = System.net.dns.gethostbyname (system.net.dns.gethostname
()). AddressList
TextBox1.Text = System.net.dns.gethostname (). ToString ()
For i = 0 To UBound (address)
TextBox2.Text = TextBox2.Text & Address (i). ToString () & Chr (+) + CHR
(10)
Next
End Sub