07-24-2023, 12:31 AM
I am trying to retrieve the user's IP address and assign it to a variable:
```
var ipAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") ||
Request.ServerVariables("REMOTE_ADDR") ||
Request.ServerVariables("HTTP_HOST");
Response.Write(Request.ServerVariables("HTTP_HOST") + "<br />\n\n"); // produces "localhost"
Response.Write(Request.ServerVariables("REMOTE_ADDR") + "<br />\n\n"); // produces "::1"
Response.Write(Request.ServerVariables("HTTP_X_FORWARDED_FOR") + "<br />\n\n"); // produces "undefined"
Response.Write("ipAddress = " + typeof ipAddress + " " + ipAddress + "<br />\n\n"); // produces "ipAddress = object undefined"
```
I am using JScript for Classic ASP. I am unsure as to what to do at this point. Can anyone help?
Thanks
```
var ipAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR") ||
Request.ServerVariables("REMOTE_ADDR") ||
Request.ServerVariables("HTTP_HOST");
Response.Write(Request.ServerVariables("HTTP_HOST") + "<br />\n\n"); // produces "localhost"
Response.Write(Request.ServerVariables("REMOTE_ADDR") + "<br />\n\n"); // produces "::1"
Response.Write(Request.ServerVariables("HTTP_X_FORWARDED_FOR") + "<br />\n\n"); // produces "undefined"
Response.Write("ipAddress = " + typeof ipAddress + " " + ipAddress + "<br />\n\n"); // produces "ipAddress = object undefined"
```
I am using JScript for Classic ASP. I am unsure as to what to do at this point. Can anyone help?
Thanks