クライアントの数値形式 ( NOT THE STRING FORMAT ) を取得する最速の方法は何ですか?
string format : 223.255.254.0
numeric format : 3758095872
次のようなコードでこれを事後計算できます
static public uint IPAddressToLong(string ipAddress)
{
var oIP = IPAddress.Parse(ipAddress);
var byteIP = oIP.GetAddressBytes();
var ip = (uint)byteIP[0] << 24;
ip += (uint)byteIP[1] << 16;
ip += (uint)byteIP[2] << 8;
ip += byteIP[3];
return ip;
}
Request.UserHostAddress 文字列に基づいていますが、IIS または ASP.NET がこれを事前計算し、HttpContext のどこかに隠されていることを望んでいました。
私が間違っている?