You can Block Country and IP Addresses in ASP.NET using HTTPModule.
1) Rule is if the IP address is in denied list or ip address is not in
granted list it will be blocked. Also, IP address will be checked
against all the defined blocking scheme in the configuration until ip is
blocked. If the IP is granted access and not in blocked list IP address
will be granted.
2) IP Address can contain * as wild character.
i.e. <ip value="127.0.0.1" access="granted" valueType="IpAddress" />
3) Range of IP address can be specified.
i.e. <ip value="127.0.0.1;127.0.0.200" access="denied" valueType="IpRange" />
4) Can block country.
i.e. <ip value="IN;US" access="denied" valueType="CountryCode" />
5) Multiple IP address blocking scheme can be defined.
i.e. grant all ip from 127.0.0.1 through 127.0.0.255 EXCEPT 127.0.0.20 through 127.0.0.25.
<ip value="127.0.0.*" access="granted" valueType="IpAddress" />
<ip value="127.0.0.20;127.0.0.25" access="denied" valueType="IpRange" />
you will get source code and step by step details
here