473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to Find the IP and location of the current User

Hi
I need the find the IP address and the Place from where he is surfing the site.
How can i find this? Please help me
Jul 5 '07 #1
1 1079
dip_developer
648 Expert 512MB
Hi
I need the find the IP address and the Place from where he is surfing the site.
How can i find this? Please help me
try this code in c# for client IP address...

Expand|Select|Wrap|Line Numbers
  1.  
  2. string hostName = Dns.GetHostName();
  3. IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
  4. foreach (IPAddress a in hostEntry.AddressList)
  5. {
  6. this.textBox1.Text += a.ToString() +Environment.NewLine;
  7. }
  8.  
or you can try:

Expand|Select|Wrap|Line Numbers
  1. string clientip;
  2. clientip=Request.ServerVariables("HTTP_X_FORWARDED_FOR");
  3. if(clientip==string.Empty)
  4. {
  5. clientip=Request.ServerVariables("REMOTE_ADDR");
  6. }
  7.  
REMOTE_ADDR does not always provide the users IP but rather the ISPs' IP address.That's why at first test HTTP_X_FORWARDED_FOR as it is the real user's IP.

or you can try........

Expand|Select|Wrap|Line Numbers
  1.  
  2. String strClientIP ;
  3. strClientIP = Request.UserHostAddress();
  4.  
hope it helps
Jul 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MightyMo | last post by:
Is it possible to detect the user's next location? I need to be able to detect if a user is abandoning the site. window.location and window.location.href triggered by onUnload can only tell me...
1
by: Matthias Ludwig | last post by:
I'm trying to create a directory on the web server with a vb.net code: .... Dim dirName As String = "w:\filepath\images" If Not Directory.Exists(dirName) Then...
3
by: David Hayes | last post by:
I've made tooltips work in Firefox*, but tooltip doesn't appear at the specified location until the SECOND time that the user passes the mouse over the location with the mouseover event. What I...
5
by: Mike Labosh | last post by:
In VB 6, the Form_QueryUnload event had an UnloadMode parameter that let me find out *why* a form is unloading, and then conditionally cancel the event. In VB.NET, the Closing event passes a...
2
by: Mark | last post by:
Hi, I am trying to open up a new window and then get the current url/location back from the (win_1) window and display the url in an alert box. Here is the code I am using :- <script...
2
by: Jeff | last post by:
I'm very new to javascript and need only a small amount in an asp.net application I'm working on. I apologize if I'm not using the correct terminology to describe the problem. I got the code below...
4
by: Karl | last post by:
Hi, I wonder if anyone could explain some options for getting the location of a visitor of a website? For instance if someone from the UK visit a website designed for US citizens, how do I...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
I placed a button on a form menustrip for the purpose of causing the horizontal scrollbar of my form to appear so that I can access controls outside of the form's current view (the controls are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.