I need to find out the subdomain from which a SOAP-based client calls a WCF-method. While that is quite easy if your’re on ASP.NET by using HttpContext.Current, I could not find an equivalent for WCF.
The reason why I need this value is, because I want to host a multi-tenant application which consists of a Web-Frontend (like “foo.myservice.com”) and also provides a SOAP-based API (like “foo.myservice.com/Services/ClientService.svc”).
Any idea?
Thany you!
Assuming that you are using HTTP based binding, you can either enable the ASP.NET compatibility to access
HttpContextor useOperationContextto gather the data you want.OperationContext.Current.RequestContext.RequestMessage.Headers.Toshould work in your case and return the Uri of the request.