0

I need to get the calling app's URL because the service sends emails that contain links to my app (e.g. click here to view the form).

I'm considering just hard-coding the app's URL in 1 place on the service, but when working locally the local host port will sometimes change. Also, when deploying to different test environments I would have to change the URL. Also, working with others will pose a slight problem too.

The best solution would be to determine it dynamically. Second best, web.config. Third best: hard code it.

How can I resolve this and get the calling app's URL?

Edit: it's impossible to send the url from the client because the service has a timed event to send email notifications.

Lifes
  • 1,226
  • 2
  • 25
  • 45
  • 1
    Does the caller necessarily _have_ a URL? If you need the URL, then have the caller send it to you. – John Saunders Jan 21 '13 at 23:18
  • possible duplicate of [Can I get the WCF Caller Url...?](http://stackoverflow.com/questions/4147636/can-i-get-the-wcf-caller-url) – Useless Jan 23 '13 at 18:10

1 Answers1

1

maybe the IP Can help

try this line

((RemoteEndpointMessageProperty)OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name]).Address;

this article can help on the long way http://keyvan.io/detect-client-ip-in-wcf-3-5

EDIT

getting the URL is not possible,

Similar question here Can I get the WCF Caller Url...?

Community
  • 1
  • 1
  • How would the IP help? I need to a link similar to: http://www.myapp.com/forms?formId=123. I just need to know the www.myapp.com/ portion of the link. – Lifes Jan 21 '13 at 23:18
  • well in that case getting the URL is not possible Similar Question here http://stackoverflow.com/questions/4147636/can-i-get-the-wcf-caller-url – Christopher Cabezudo Rodriguez Jan 22 '13 at 17:39
  • I figured as much: thanks. Could you put that in an official answer and I'll mark it as correct. – Lifes Jan 22 '13 at 20:20