Thursday, May 14, 2009

Get Remote Client's IP Address and UserName.

In we can get IP Address of WebClient using Request object.and If User is Loggen in With Some Authentication like Forms,Windows or any other. we can also track detail of User Loggen in User on that Web Site.

string strIpAddress = string.Empty;
strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIpAddress == null)
strIpAddress = Request.ServerVariables["REMOTE_ADDR"];

In above Code strIpAddress will Contain IP of Client machine..
this will not show up real IP if your Client is Behind LAN firewalls.


the code in above line will returns UserName . If User is Loggen in..


1 comment:

  1. Hai,
    I found internet ip address using this site www.ip-details.comBut From Your Article i learned how to
    "Get Remote Client's IP Address and UserName.".Thanks for your info.


Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author