Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Misc

Restrict access to ASPRunnerPro application by IP address

Scroll Prev Next More

 

Restricting or allowing access by an IP address is an easy task. Here are a few examples. The code needs to be added to the beginning of the AfterAppInit event.

 

Note: This tutorial uses IPv4 addresses.

Allow local access only:

if Request.ServerVariables("REMOTE_ADDR")<>"127.0.0.1" then Response.End

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

Restrict access from a certain IP address:

if Request.ServerVariables("REMOTE_ADDR")="96.23.12.124" then Response.End

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

See also:

Security screen

Advanced security settings

Registration and passwords

Active Directory