There is a post request coming to my portal and I am fetching IP address from the post request on my portal landing page(INDEX view in MVC) and saving in DB table. below is the code to fetch IP address.

string Device_IP = "";
if (!string.IsNullOrEmpty(Request.ServerVariables["HTTP_VIA"]))
//           ' using proxy
//          ' Return real client IP.            
    Device_IP = Convert.ToString(Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
//    'not using proxy or can't get the Client IP
//    'While it can't get the Client IP, it will return proxy IP.
                Device_IP = Convert.ToString(Request.ServerVariables["REMOTE_ADDR"]);

It is fetching IP address on my side but on client side when request is made code is not working. same code working fine on other sites.

what are the possible causes and solution for this issue?