0

I want to get a user IP address from asp.net web API application. I am using angular 6 and asp.net web API. My API always returning the angular application's hosted IP address, not the user IP address. Below is the sample code which I am using

string HTTP_X_FORWARDED_FOR = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(HTTP_X_FORWARDED_FOR))
{
    var s = HTTP_X_FORWARDED_FOR.Split(',');
}
string REMOTE_ADDR = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
zx485
  • 28,498
  • 28
  • 50
  • 59

0 Answers0