2

Possible Duplicate:
How to get a user's client IP address in ASP.NET?

I have a application in which i have to get IP address of user who accessing my site. My site is hosted on Go Daddy hosting server. I have tried several codes(which are listed below) but it seems they are not working.

HttpContext.Current.Request.UserHostAddress.ToString(); 

Request.UserHostAddress.ToString();

Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

Request.ServerVariables["REMOTE_ADDR"];

HttpContext.Current.Request. Server Variables["HTTP_X_FORWARDED_FOR"];

I have been working on this since last 3 days but i could not find any good solution. Any good solution for this.

Please help me to do this.

Thank you.

Community
  • 1
  • 1
Bhargav Panchal
  • 39
  • 1
  • 3
  • 6

3 Answers3

3

I think you can use HttpRequest.UserHostAddress

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
0

May be this could help

System.Net.Dns.GetHostByName(Environment.MachineName).AddressList[0].ToString()
Chief
  • 914
  • 1
  • 9
  • 26
0

Those should work. Are you expecting to get the IP address of your computer On your network? (as opposed to the public one given by your ISP, that could change)

George Duckett
  • 31,770
  • 9
  • 95
  • 162