user3428422
user3428422

Reputation: 4560

.net HTTP_X_FORWARDED_FOR NULL on localhost

Apologises if this has been answered else where, I could not find it.

In the case it has not, I am trying to find the original IP of a machine who has accessed the site.

In my basic understanding, the variable HTTP_X_FORWARDED_FOR will display the user's IP regardless of proxy's and other filters. if this is true, I am trying to code this but I get a null string

System.Web.HttpContext context = System.Web.HttpContext.Current;
string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; 

Possible problems are HTTP_X_FORWARDED_FOR doesn't appear in the HTTP HEADERS / server variable list, or I am using localhost? Using REMOTE_ADDR, the localhost IP is displayed.

Am I on the right lines or is my understanding incorrect?

Thanks

Upvotes: 4

Views: 4939

Answers (1)

Hussein Zawawi
Hussein Zawawi

Reputation: 2937

HTTP_X_FORWARDED_FOR header usually hold proxy values so it is normal you dont see any content on your local machine since you are not going through any proxies

Upvotes: 5

Related Questions