October 6th, 2006

Block visitors based on IP address with ASP

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

One Response to ' Block visitors based on IP address with ASP '

Subscribe to comments with RSS or TrackBack to ' Block visitors based on IP address with ASP '.

  1. sdsd said,

    on December 9th, 2006 at 1:18 am

    dfdfdfdfdfdfdf

Leave a reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word