Click here to Skip to main content
16,014,591 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi Guys,

How to get visitor ip address in asp.net using javascript ..
I tried too much . but I cant get exact solution.
Please help me any one..

Thank you
S.vinodkumar
Posted

You can't get the IP address at the client side - you have to refer to the server. The Client side IP is a local address (192.xxx.xxx.xxx or similar) which does not extend past the router. Equally, the Server cannot see the Client actual IP - it sees the IP address of the actual router, which is assigned by the ISP.

The easiest way to do it is to ask the server:
HTML
<br />Your IP address is <%= Request.ServerVariables["REMOTE_ADDR"] %><br />
 
Share this answer
 
Try this one

XML
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script type="text/javascript" >
function ClientIP()
{   $.getJSON("http://jsonip.appspot.com?callback=?", function (jsonResult) {
    $('#ClientIP').html("Your Ip Address is :"+jsonResult.ip);
        });

}
</script>


<div id="ClientIP"></div><br />
 
Share this answer
 

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