Hello everyone,
i'm only slightly familiar with asp.net but i'm very familiar with
c#/vb.net and i'm writing an application that needs to know my machines
Global IP address. I'm behind a NAT enabled router so i know it's different
than my local ip address. i'd like to do this via an httprequest.
When you say "my machine" in this case do you mean your local web server
(in which case presumably you're port forwarding in addition to NAT), or
do you mean the web client?
In any case, the only reliable way to do this is to keep a small app in
a known location on the internet someplace that will return the
information you want. Then from your local machine you can send out a
request to the known machine, which then returns the IP address in html,
or xml, or a web service, or whatever. There's a bunch of sites that do
that right now, but a) it might not be a good idea to rely on the
stability of others' sites, and b) it's probably a little rude to use
their services without asking.
I do wish one of the major player would stick up a web service someplace
that would do this and promises to be around a long time. It would be
pretty useful IMHO.
Another poster mentioned asking the router, which is absolutely correct
and might work fine in your situation since you're dealing with a known
router. If you don't know where your app is going to live though, for
example if it's something you're distributing to others, this won't work
because you won't know where the NAT router is.
Lastly, you might want to rethink whether you really need this info for
your app.