0

This would be easier if I were able to have the external computer get its own name and just pass it to a web service as a variable, but I'm not able to do that right now. There are a variable number of computers from several different entities that regurarly access a web service on one of our servers. Changing only some VB.Net code on the server and nothing at all on any of those external computers, how would I be able to get their names programmatically in VB.Net? Thanks!

EDIT: Some of the answers look like they're designed to get the IP of either the server, the server's router, or something else along those lines. Maybe I'm just misreading the code or something, but I was talking about getting the names of client, external computers who try to access a webmethod on the server, using the webmethod's code to do so.

Panzercrisis
  • 4,590
  • 6
  • 46
  • 85
  • if this is a WCF service, see [this question](http://stackoverflow.com/questions/5034660/how-to-retrieve-the-clients-machine-name-from-within-a-wcf-operation-contract). – Jason May 02 '12 at 14:56

3 Answers3

1

If there is no address translation and computers has DNS entries:

Dim ip As String = System.Web.HttpContext.Current.Request.UserHostAddress
Dim name as String = System.Net.Dns.GetHostEntry(ip).HostName()
IvanH
  • 5,039
  • 14
  • 60
  • 81
1
System.Net.Dns.GetHostAddresses(My.Computer.Name)(5).ToString
0

Quick solution for getting external IP in VB.Net

Dim sIp As String
Dim webClient As System.Net.WebClient = New System.Net.WebClient() 
sIp = webClient.DownloadString("http://lbb.ie/ip.php")

And that's it It is my own php file on my own server so go ahead :) Enjoy

Tomas
  • 1