Ban a user based on IP address

Submitted by:Tim Kelly

Date added:16 February, 2012

Category:ASP

ASP code example how to ban a user by IP address

Tags: ban ip

Code Snippet:

<% 
'variables to store banned IP and the users IP
Dim strIP , strBannedIP
'this is the banned IP address
strBannedIP = "127.0.0.1"
'get the users IP address
strIP = Request.ServerVariables("LOCAL_ADDR")
'if users address is the same as the banned IP address
'display a message
If strBannedIP = strIP Then
Response.Write "You are not permitted to view this website"
'if users address is different welcome message is displayed
Else
Response.Write "welcome"
End If
%>
 
 

Comments