I have a website hosted through IIS and want to have an include . In that testfile.aspx I want to get the IP address of the client and redirect based off of requirements. However when I try to get the ip address I am given the ip of the machine my website is being hosted on and not the user
How to get a user's client IP address in ASP.NET?
I have tried all the methods in the link above and they all return the ip address of the host machine. Ive tried the code in the include page as well as the code behind of a sample test page and it still does not work.
Version 1
Dim ipAdd As String
ipAdd = Request.ServerVariables("REMOTE_ADDR")
ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('This is your ip " & ipAdd & "');", True)
Version 2
ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('This is your ip " & Request.UserHostAddress & "');", True)
Both those methods return the public ip of my IIS web server