如何在C#中获取IPv6地址? [英] How to get IPv6 Address in c#?
问题描述
我用Request.UserHostAddress
,只能获取IPv4地址,如何获取访问者的IPv6地址?
I use Request.UserHostAddress
, can only get IPv4 address, how to get IPv6 address of a visitor?
推荐答案
我假设您是在谈论HttpRequest.UserHostAddress
.它将始终返回用于连接到您的地址.如果请求是通过IPv6发出的,它将返回其IPv6地址;否则,将返回其IPv6地址.如果请求是通过IPv4发出的,它将返回其IPv4地址.
I assume you're talking about HttpRequest.UserHostAddress
. It will always return the address that was used to connect to you. If the request was made over IPv6, it will return their IPv6 address; if the request was made over IPv4, it will return their IPv4 address.
您应该首先调查为什么通过IPv4发出请求. http://serverfault.com 上的人们可能会对此有所帮助.
You should start by investigating why the request is being made over IPv4. And the folks at http://serverfault.com will probably be of more help on that.
这篇关于如何在C#中获取IPv6地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!