0

I've a WCF service that is accessible through 2 differents bindings, one TCP and one NamedPipe. The NamePipe one is used only locally for speed reason, and on the Service side I need to know if I've been called locally(from the same computer, through the namedpipe) to enforce some licensing constraints.

What would be the way to go? I've seen there is a OperationContext.Current but I didn't find any information on the current binding in use, so I guess there is another way to get it(or at least know that I've been called from the same computer).

J4N
  • 19,480
  • 39
  • 187
  • 340

1 Answers1

0

You may want to use System.ServiceModel.Channels.MessageProperties

OperationContext context = OperationContext.Current;
// check if context is not null
MessageProperties messageProperties = context.IncomingMessageProperties;

If the request came from a browser, you will get a HttpRequest object, which contains a property IsLocal which true if the request is from the local computer; otherwise, false.

Hope this helps !

Community
  • 1
  • 1
Ankit
  • 5,733
  • 2
  • 22
  • 23
  • Well, my goal is more to know if the call has been made locally or remotely(and in my case it's either from a TCP Binding or a Named Pipe binding). So the request will not contains any HttpRequest with a IsLocal property – J4N Jul 24 '17 at 08:28
  • Understood, you will not receive HttpRequest object, however you may try to examine IncomingMessageProperties for both cases i.e. TCP Binding or a Named Pipe binding and see if there is anything which might help you to distinguish requests from different clients, do update your findings on this question. Happy Programming ! – Ankit Jul 24 '17 at 08:53