Request.ServerVariables(“..”) returns undefined when assigned to a variable yet its value can be displayed via Response.Write(“..”)
问题 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