Client IP Adresse mittels Javascpript auslesen
M=F6chte man auf Browser Seite die IP Adresse des Cl=
ients auslesen kann das wie folgt bewerkstelligt werden.
Javascript
<script type=3D"application/javascript">
function
getIP(json)
{
document.write=
("My
public IP address is: ", json.ip);
}
</script>
<script type=3D"application/javascript"
src=3D"https://api.ipify.org?format=3Djsonp&callback=3Dg=
etIP"></script&=
gt;
JQuery
lt;script type=3D"application/javascript"=
>
$(func=
tion() {
=
$.getJSON("https://api.ipify.org?form=
at=3Djsonp&callback=3D?",=
=
&=
nbsp; function(json) {
&=
nbsp; document.write(&qu=
ot;My public IP address is: ", jso=
n.ip);
&=
nbsp; }
);
});
</script>
C#
;
using System=
.Net;=
=
namespace Ipify.Examples {
=
class Program {
&=
nbsp; public static void=
Main (string[] args) {
&=
nbsp; WebClient webClient =
=3D new WebClient();
&=
nbsp; string publicIp =3D webClient.DownloadString("https://api.ipify.org");
&=
nbsp; Console.WriteLine("My public IP Address is: {0}", publicIp);
&=
nbsp; }
=
}
}=
VB.net
WebClient
Dim ip as String =3D c=
lient.DownloadString("https://api.i=
pify.org")