[Mono-list] Help on get client IP on webservice
Adam Tauno Williams
awilliam at whitemice.org
Tue Mar 10 11:46:29 EDT 2009
On Tue, 2009-03-10 at 14:09 +0100, Xavi de Blas wrote:
> 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:
> HttpListener listener = new HttpListener();
> HttpListenerContext context = listener.GetContext();
> HttpListenerRequest request = context.Request;
> Console.WriteLine("ip: " + request.UserHostAddress);
> Can anyone help me?
It is not possible IMO; not reliably anyway, as lots of things can mask
it. The value is essentially worthless.
More information about the Mono-list