In Asp.NET Is there any way to restrict access from certain country by checking IP address. So far I changed web.config file. I gather ip adresses from third party API. However it gives the error that I attached screen shot of it.
Any help would be great. Thanks in advance
Here is my webconfig;
<system.webServer>
<security>
<ipSecurity allowUnlisted="true">
<clear/>
<add ipAddress="5.2.80.0" subnetMask="255.255.248.0"/>
<add ipAddress="5.10.140.0" subnetMask="255.255.255.0"/>
<add ipAddress="5.11.128.0" subnetMask="255.255.128.0"/>
<add ipAddress="5.23.0.0" subnetMask="255.255.255.0"/>
<add ipAddress="5.23.16.0" subnetMask="255.255.255.248"/>
<add ipAddress="5.23.120.0" subnetMask="255.255.248.0"/>
<add ipAddress="5.24.0.0" subnetMask="255.252.0.0"/>
<add ipAddress="5.44.80.0" subnetMask="255.255.240.0"/>
<add ipAddress="5.44.144.0" subnetMask="255.255.240.0"/>
<add ipAddress="5.46.0.0" subnetMask="255.254.0.0"/>
<add ipAddress="5.62.126.0" subnetMask="255.255.254.0"/>
<add ipAddress="5.63.32.0" subnetMask="255.255.224.0"/>
<add ipAddress="5.104.0.0" subnetMask="255.255.240.0"/>
<add ipAddress="5.159.248.0" subnetMask="255.255.248.0"/>
<add ipAddress="5.176.0.0" subnetMask="255.254.0.0"/>
<add ipAddress="5.226.192.0" subnetMask="255.255.192.0"/>
<add ipAddress="5.229.0.0" subnetMask="255.255.0.0"/>
<add ipAddress="5.250.240.0" subnetMask="255.255.240.0"/>
<add ipAddress="5.255.0.0" subnetMask="255.255.192.0"/>
<add ipAddress="23.229.3.0" subnetMask="255.255.255.0"/>
<!-- ...
...
...
... -->
</ipSecurity>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
And here the result
From this article, it looks like the problem is related to your service provider locking that security setting at a higher level and preventing the override.
the section is locked at a higher level such as applicationhost.config
And here's a link to the page about how to lock these settings: http://www.iis.net/learn/get-started/planning-for-security/how-to-use-locking-in-iis-configuration
User contributions licensed under CC BY-SA 3.0