Introduction In this code lets see how to find system or client machine IP address from which user visited the website in asp.net...
Description Simply add label in .aspx page and write the below coding in pageload section
protected void Page_Load(object sender, EventArgs e)
{
string ipadd = string.Empty;
//"HTTP_X_FORWARDED_FOR" will return the user ipadd if client is behind proxy server
ipadd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ipadd))
{
//"REMOTE_ADDR" will return the ipaddress of router
ipadd = Request.ServerVariables["REMOTE_ADDR"];
Label2.Text ="your ipaddress is" + ipadd;
}
}
Conclusion in this way we can check the user's ipaddress, either user is behind the proxy server or not