1
我可以從asp.net獲取ios設備的本地ipaddress嗎?我想獲得一個IOS設備的IP地址,並希望存儲到數據庫中。如何從asp.net c#中的ios設備獲取本地ip地址?
我可以從asp.net獲取ios設備的本地ipaddress嗎?我想獲得一個IOS設備的IP地址,並希望存儲到數據庫中。如何從asp.net c#中的ios設備獲取本地ip地址?
您可以使用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
感謝重播。但我想獲得使用C#可能獲得在C#? –
你的意思是Xamarin(以前的單觸式)? –
不使用以前的單點觸摸,但我在C#中開發一個IOS Web應用程序,所以我想從哪裏來請求本地ip的IOS設備。所以我想在C#asp.net –