I have a xml with many Ip addresses. Like this:
<settings>
<ipaddresses>
<ipaddress>1288</ipaddress>
<ipaddress>1999</ipaddress>
<ipaddress>555</ipaddress>
<ipaddress>88888</ipaddress>
</ipaddresses>
</settings>
And Now I want to check if one of the Ip Addresses match the Ip address of a pc. So that that user is allowed to see the product.
If the one of the Ipaddresses in the XML not match the Ipaddress of the pc, then a error message has to return. I try it like this:
XDocument doc = XDocument.Parse(product.AuthenticationSettings);
var IpAddress = doc.Descendants("ipaddress");
foreach (var IpAddresses in IpAddress)
{
bool IppAddressMatch = false;
if (GetClientIp() == IpAddresses.Value)
{
IppAddressMatch = true;
}
if (GetClientIp() != IpAddresses.Value)
{
// log message
return Content("<h1>403 Forbidden</h1>", "text/html");
}
}
But I get this error:
Error 6 Warning as Error: The variable 'IppAddressMatch' is assigned but its value is never used