I previously posted this code in PHP, and I thought it would be handy to have the ASP alternative, in case you need to block visitors or known spammers based on their IP address.
Function IsBlockedIP()
Dim UserIP
Dim BlockedIParray(2) ' you can create the array larger of course
'put each blocked IP address in the array
BlockedIParray(0) = "60.0.201.209"
BlockedIParray(1) = "218.11.15.212"
'retrieve the visitors IP address from the server variables
UserIP = Request.ServerVariables("REMOTE_ADDR")
'loop through the Blocked IPs
For i = 0 to UBound(BlockedIParray)
If UserIP = BlockedIParray(i) Then
Response.Redirect "blocked.asp"
End If
Next
End Function
Sign up for our daily email newsletter:
You must log in to post a comment.