我可以从asp.net获得ios设备的本地ipaddress吗?我想获得一个ios设备的ip地址,并希望存储到数据库中。
答案 0 :(得分:0)
您可以使用ifaddrs
获取IP地址。例如,例如在这里:iPhone/iPad/OSX: How to get my IP address programmatically?
并且您可以使用Web服务(asmx或WCF)将IP地址发送到基于ASP.NET的服务。例如一个例子这里:
http://highoncoding.com/Articles/809_Consuming__NET_Web_Services_in_an_iOS_Application.aspx
UDPATE:
根据您的澄清,这可能是您需要的:
Request.ServerVariables["REMOTE_ADDR"], //the address, but if you are behind e.g. badly configured load balancer the IP will be not of the origin of the request
Request.ServerVariables["HTTP_X_FORWARDED_FOR"] //if you are behind proxy or load balancer, this is where the original IP address should be