Click here to Skip to main content
16,020,347 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hello All

I am trying to capture an user computer IP address using java-script and json. I am always getting public IP or server IP but not local IP. can you please help me if anyone come across this.

Thanks in advance


What I have tried:

I tried Request.ServerVariables["Remote_Addr"] is giving server ip and tried json url to get ip but it is giving the public ip
Posted
Updated 22-Jul-16 4:21am

you can check this link out:

http://www.codeproject.com/Questions/798310/How-to-get-local-ip-address-using-javascript
 
Share this answer
 
Comments
venky_115 22-Jul-16 10:22am    
Thanks for your reply, I tried the above link but it is giving me the below error, can you please suggest

0x800a138f - JavaScript runtime error: Unable to get property 'ip' of undefined or null reference
Some proxy servers might include this information in either the Forwarded[^] or X-Forwarded-For[^] headers. However, most do not, and this information is easy to forge.

For the most part, the local IP address does not leave the local LAN, and would be meaningless outside of the local LAN.
 
Share this answer
 
Comments
venky_115 22-Jul-16 10:29am    
yes, we need this for our local auditing purpose. facing difficulty to capture this :)
Richard Deeming 22-Jul-16 10:34am    
As I said, it usually doesn't escape the local LAN, and wouldn't have much meaning if it did. How were you planning to differentiate between 15 users from different networks, all with the local IP address 192.160.0.42?

And the optional headers which might pass that information through are easy to forge, so they're not much use for auditing.

The only time I can recall seeing the local IP address exposed is when there's a security vulnerability in the browser. Those tend to get fixed pretty quickly, so even if you found one, you couldn't rely on it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900