0

I'm fairly new to WCF. I want to send the client an URL, which points to a file on the server, so the client can download\view it.

So my idea is that I add the relative path to the IP the service is listening on.

Like http://86.1.2.3:8123/myfolder/myfile.rar

The problem is, that every solution I found gives back

   localhost:someport/mysite

Obviously, this is not really useful for the client.

Is there even a way to get the public IP from the code on which the service is hosted?

Or should I just include the address in the config file, and change it whenever the IP changes?

EDIT: Thanks for the quick help guys, I will just include it in the config file then.

Akif
  • 7,098
  • 7
  • 27
  • 53
Attila
  • 41
  • 3

2 Answers2

0

Well, first of all, if you have no server application running (I.E Apache, etc), nothing will be able to connect to your endpoint. You may use a service like WAMP for this. Second, you need to forward whatever port you're using to be able to serve the file (this is done on your router config). No, there is no way to predict what the IP of the server it's connecting to is going to be ahead of time. This will have to be added to the client codebase manually. Finally, if this is going to be used in a production environment, I would STRONGLY recommend that you do not use something like WAMP, or a local environment at all, for something like this.

Brandon Miller
  • 1,534
  • 1
  • 11
  • 16
0

You need to call an external service, like whatismyip.com, and parse the response. There is no standard format for the response, hence not very reliable. Answered here: Get public/external IP address?

Shankar
  • 1,634
  • 1
  • 18
  • 23