Im looking for a way to block specific IP addresses and net blocks from accessing all pages. I assume the best place to do this is the Global.asax page. I would love to do this in IIS but in a hosted environment this in not possible. Any ideas, code? suggestions? Thanks,
In the Session start - event handler: say you have an array of blocked IP's i.e. Dim bArr() As String = {"198.122.xxx.xx", "xxx.xxx.xx.xxx" etc.} Code (markup): Dim strIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If strIP="" Then strIP = Request.ServerVariables("REMOTE_ADDR") For i As integer = 0 To bArr.UperBound If strIP = bArr(i) Then Response.Redirect("Permissionsdenied.html") End If Next Code (markup): HTH Regards
Have a look at this project at CodeGuru http://www.codeguru.com/csharp/.net/net_general/internet/article.php/c10651