Restricting or allowing access by IP address is an easy task. Here are a few examples. This code needs to be added to the beginning of AfterAppInit event. Please note that this tutorial uses IPv4 addresses.
- Allow local access only
if Request.ServerVariables("REMOTE_ADDR")<>"127.0.0.1" then Response.End
2. Allow access from the list of approved IP addresses.
Dim arr(2)
arr(0) = "127.0.0.1"
arr(1) = "127.0.0.2"
arr(2) = "127.0.0.3"
bGood=false
For Each item In arr
if item = Request.ServerVariables("REMOTE_ADDR") then
bGood=true
Exit For
end if
Next
if not bGood then Response.End
3. Restrict access from a certain IP address
if Request.ServerVariables("REMOTE_ADDR")="96.23.12.124" then Response.End
4. Restrict access from the list of addresses
Dim arr(2)
arr(0) = "127.0.0.1"
arr(1) = "127.0.0.2"
arr(2) = "127.0.0.3"
For Each item In arr
if item = Request.ServerVariables("REMOTE_ADDR") then
Response.End
end if
Next