[Mono-list] Help on get client IP on webservice

sojan sojankallara at yahoo.com
Tue Mar 10 22:01:01 EDT 2009


check the /etc/hosts file 
a sample hosts file should be like the following 

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1	localhost.localdomain	localhost
::1	localhost.localdomain	localhost6	localhost
192.168.1.111	sojan.net	sojan


Xavi de Blas-2 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:
> 
> //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
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-on-get-client-IP-on-webservice-tp22433867p22447505.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list