To achieve this use below line of code:
- string IPAddress = string.Empty;
- IPAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
- if (IPAddress == "" || IPAddress == null)
- IPAddress = Request.ServerVariables["REMOTE_ADDR"];
- Response.Write("<b>Your Machine IP Address is: </b>" + IPAddress);
Image 1.