I am using the Microsoft.AspNetCore.HttpOverrides.IPNetwork class to check to see if an ip address is in a subnet, but the result is not what I expect
void Main()
{
var ipnw = new Microsoft.AspNetCore.HttpOverrides.IPNetwork(
IPAddress.Parse("10.10.10.1"), 30);
// expect these to be true
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.0")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.1")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.2")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.3")));
// expect these to be false
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.4")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.5")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.6")));
Console.WriteLine(ipnw.Contains(IPAddress.Parse("10.10.10.7")));
}
I get all false, and I don't understand why. I found a free online site for checking (horrible interface) at https://tehnoblog.org/ip-tools/ip-address-in-cidr-range/, and it shows what I expect...
What am I doing wrong?