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
2009-06-22 22:42:10
A:
You want to do an nslookup.
Here's an example:
http://www.c-sharpcorner.com/UploadFile/DougBell/NSLookUpDB00112052005013753AM/NSLookUpDB001.aspx
Chris Harris
2009-06-22 22:42:30
A:
IPHostEntry Host = Dns.GetHostEntry(DNSNameString);
DoSomethingWith(Host.AddressList);
chaos
2009-06-22 22:47:11
Thanks guys for your help but I want to get the visitor's IP address not the pc im working on
2009-06-22 23:11:27
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
2009-06-22 23:21:17
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
2009-06-22 23:27:32