views:

526

answers:

5

How can you dynamically get the IP address of the server (PC which you want to connect to)?

+9  A: 

System.Dns.GetHostEntry can be used to resolve a name to an IP address.

Michael
A: 

You want to do an nslookup.

Here's an example:

http://www.c-sharpcorner.com/UploadFile/DougBell/NSLookUpDB00112052005013753AM/NSLookUpDB001.aspx

Chris Harris
A: 

Got this on google. Perhaps it might help.

http://www.biztalkgurus.com/forums/t/2057.aspx

OrangeRind
A: 
IPHostEntry Host = Dns.GetHostEntry(DNSNameString);
DoSomethingWith(Host.AddressList);
chaos
Thanks guys for your help but I want to get the visitor's IP address not the pc im working on
Erm. My example is nothing to do with the PC you're on. DNSNameString is meant to be the name of the server you're connecting to -- that is, answering the original question. I don't know where this stuff you're saying about a visitor's IP address comes from or what it has to do with the question.
chaos
A: 

Based on your comment on chaos's answer, you don't want the IP address of a server, you want the IP address of a client. If that's the case, fix your question ... and your answer would be HttpRequest.UserHostAddress.

Richard Hein