UserHostAdress question

0
0

I run my WiseJ application behind a reverse proxy (traefik) and try to detect the users IP address using “Application.UserHostAddress”.
This seems to provide the local/private IP address of the client (e.g. 192.168.x.x).
Is it also possible to get the public IP address of the internet router ? In another ASP.net Core application I use “HttpContext.Request.Headers[“X-Real-Ip”]” for detecting the IP which provides the public IP.

  • You must to post comments
0
0

Application.UserHostAddress is the same as HttpRequest.UserHostAddress which corresponds to “REMOTE_ADDR” (https://docs.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms524602(v=vs.90)). All server variables are available as Application.ServerVariables[name].

Usually proxies add “X-Forwarded-For”, but “X-Real-IP” could work if available. Try with Application.ServerVariables. If it’s not there, you can always use HttpContext.Current.Request.Headers in Program.Main since it’s the first HTTP request.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.