Using Web.Config to Allow/Deny Access to an Specific IP

Applications must have an IP blocking feature in order to deny access to certain computers that could attack your site. But this can also be useful if you want to give access to your ASP application to just one person. In this article I will give you a step-by-step guide on how to allow or deny access to an specific IP using Web.ConfigOverview

As discussed before, the web.config is the main settings and configuration file for  Asp.Net applications. It controls the behavior of your application and lets you and since the Web.Config file is stored in XML format, it is easy to work with. If we want to change the behavior of the application(such as denying access) you just need to use the appropriate tag element.

Getting Started

1. Open your project.

2. Open the web.Config file of your application. Look for the <system> tag:

open webconfig file arvixe asp tutorials iis hosting windows hosting

3. Now, let’s add the code. For the purposes of this tutorial, we are going to allow access to our ASP application to the following IP:

IP Address: “”

4. Open a <security> element tag. Below it we will deny access to anyone by opening the <ipSecurity> element tag and setting “allowUnlisted” to false:

       <ipSecurity allowUnlisted="false">    

security tag asp tutorials hosting deny

5. Now, insert a <clear/> tag. Below that tag, we will set the IP address that will have access to the application:


       <add ipAddress="" allowed="true"/>
       <add ipAddress="" subnetMask="" allowed="true"/>


allow one deny all asp tutorials arvixe hosting windows iis

Note: Remember that you need to close the <ipSecurity> and <security> element tags.

6. Save your changes.

7. And that’s it! Only one IP address is allowed to view the application!

This concludes Using Web.Config to Allow/Deny Access to an Specific IP

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Tags: , , , , , , , , , | Posted under ASP .NET 4.0 | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

Leave a Reply

Your email address will not be published. Required fields are marked *