[Mono-list] Help on get client IP on webservice
Xavi de Blas
xaviblas at gmail.com
Tue Mar 10 09:09:37 EDT 2009
Hello all, i read a lot of info on the net, but had no success in
getting the client IP on a webservice connection.
This doesn't show me client ip:
string strHostName = "";
strHostName = System.Net.Dns.GetHostName();
IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;
string ip = addr[addr.Length-1].ToString();
Console.WriteLine("ip: " + ip);
And this doesn't work for me:
//http://lists.ximian.com/pipermail/mono-list/2007-January/033998.html
HttpListener listener = new HttpListener();
listener.Start();
HttpListenerContext context = listener.GetContext();
HttpListenerRequest request = context.Request;
Console.WriteLine("ip: " + request.UserHostAddress);
Can anyone help me?
Thanks
More information about the Mono-list
mailing list