简体   繁体   中英

C# to get accurate client ipv6 public address

Using the below C# to get ipv6 is inaccurate for my test site, when i compare the site https://test-ipv6.com/ ipv6 value is different.

I think how to using C# to get ipv6 value same as the https://test-ipv6.com/ ipv6 value. It is using same client, i curious why i cannot find the ipv6 info, including the headers.

The below code is using .net 5 (C #)

HttpContext.Connection.RemoteIpAddress.MapToIPv6().ToString();

If you map an IPv4 to IPv6, the IPv4 is just represented as IPv6.

If your client connects using IPv4, then you can't obtain their IPv6 address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM