IPV6 cutted on CustomerIP fields

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi!

I have seen IPV6 cutted to the first part only in CustomerIP fields.

Do you know why and how to fix it? If it is a nop bug or not?

For example:

2804:07f3:4980:a809:3cf6:c6db:16af:1111

is stores as 2804 only.

Thanks!
5 years ago
Does anyone have a solution for this? I'm also having this issue. I'm using nopCommerce 3.6.
Thanks.
3 years ago
Anyone ever figure out why this happens?  Happening to my site (4.3) now as well.

Thanks!
3 years ago
If you have the source code then have a look at the GetCurrentIpAddress method in Core/WebHelper, it occurs in the last line that splits on the ":"
(see below)

Here is an example for how to use IPAddress.TryParse for IPv6 format:
https://stackoverflow.com/questions/799060/how-to-determine-if-a-string-is-a-valid-ipv4-or-ipv6-address-in-c


//"TryParse" doesn't support IPv4 with port number
if (IPAddress.TryParse(result ?? string.Empty, out var ip))
    //IP address is valid
    result = ip.ToString();
else if (!string.IsNullOrEmpty(result))
    //remove port
    result = result.Split(':').FirstOrDefault();
3 years ago
It's not an IPV4 though so it should not even be getting to that section of code
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.