[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Check if connection to website is from external source

I want to check if a user is connecting to a site from our intranet or outside of it and redirect them if they are coming from outside.
0
UnderSeven
Asked:
UnderSeven
  • 2
1 Solution
 
sammySeltzerCommented:
This is how I owuld approach it.

'Create a variable to hold your IP address.  

Dim ipAddress As String = ""


'Retrieve the user's ip address from Page_Load():

ipAddress = Request.ServerVariables("REMOTE_ADDR")

'Then compare the retrieved IP address to the subnet for your network which is usually "192.168.0"  or whatever it is. You can find out from your network admins.

If ipAddress.Contains("192.168.0") Then
	Response.Write("an internal user ")
Else
	Response.Redirect("someplace else")
End If

Open in new window

0
 
UnderSevenAuthor Commented:
Yep worked just fine.
0
 
sammySeltzerCommented:
Congrats and thanks for the points.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now