I have a group of IP addresses.
After deploying my application, I want to only be able to access my application from a particular IP address.
How can I achieve this using the Global.asax (not through IIS)?
I have a group of IP addresses.
After deploying my application, I want to only be able to access my application from a particular IP address.
How can I achieve this using the Global.asax (not through IIS)?
In the Session start - event handler:
say you have an array of blocked IP's i.e. Code (text):
Dim bArr() As String = {"198.122.xxx.xx", "xxx.xxx.xx.xxx" etc.}
Code (text):
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
I would start in this way, in the begin request event handler in your Global class, I would determine the client IP address following this answer: https://stackoverflow.com/a/9567439/559144
then if the connecting ip is not in the allowed list, I would redirect to another page like an access denied page, a login page or the company / google home page.