Reputation: 1345
I've inherited from a another team a WCF Web Service devloped on .net framework 3.5. When installed on a Sandbox, the WS URL looks like this:
URL: https://<EnvironmentName>/fr/webservices/<someWebServiceName>.svc
What I was requested is to get that URL from the Web Service Method code during the WS execution ( runtime ). Do you have any idea?
I would tend to think there should be a environment variable which can be easily used to get the URL. Any contribution will be appreciated.
Thanks!
Upvotes: 3
Views: 5012
Reputation: 1345
[Update]: With the help provided by @MichelZ, I've been able to address my question. Here's the code:
var context = OperationContext.Current;
string requestedUrl = context.EndpointDispatcher.EndpointAddress.Uri.ToString();
Thank you all!
Upvotes: 0
Reputation: 4394
var context = OperationContext.Current;
var requestedUrl = context.IncomingMessageHeaders.To.PathAndQuery;
Upvotes: 3
Reputation: 488
The OperationContext is available and should provide what you're looking for, specifically:
OperationContext.Current.EndpointDispatcher.EndpointAddress.Uri
Upvotes: 4