How to capture end user ip address accessing a website.

Posted by dotnet_faq-2452 under ASP.NET on 11/3/2009 | Views : 2842 | Status : [Member] | Replies : 2
I want to capture ip address of end user accessing our intranet site.(from outside/ within the company).
I tryed with different code snipets , but i am getting server ip address(gateway ip) , not the end user's.




Responses

Posted by: SheoNarayan on: 11/3/2009 [Administrator] HonoraryPlatinum

Up
0
Down
You can try with
Request.UserHostAddress;


Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

dotnet_faq-2452, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Virendradugar on: 11/4/2009 [Member] [MVP] Silver

Up
0
Down
Hi,

Use this code.

string compname;

compname = System.Net.Dns.GetHostName().ToString();
IPAddress[] ipHost;
ipHost = Dns.GetHostAddresses(Dns.GetHostName());
string strIpAddrees = ipHost[0].ToString();


Also, include this reference to make this code work.

using System.Net;


Hope this helps!!!


dotnet_faq-2452, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response