0

I have a WCF WebServiceHost with WebHttpBinding.

I don't want to reply to IPs that are not whitelisted to hide the presence of the service, rather than answering with a 404 error.

I have tried without success:

OperationContext.Current.Channel.Close() / Abort()

Throw New InvalidOperationException()

Kill the thread but no new connection can be established

My service behavior is set to

InstanceContextMode.PerSession
ConcurrencyMode.Single

Any idea?

Tofnet
  • 185
  • 2
  • 5
  • Maybe you can try using `ServiceHost.Close()`, you can check https://stackoverflow.com/questions/4964161/wcf-how-to-stop-myservicehost-close-from-disposing-of-myservicehost-object – Lan Huang Feb 21 '22 at 03:14
  • Or the client should close the service channel https://stackoverflow.com/questions/8492469/wcf-callback-interface-who-closes-the-channel. – Lan Huang Feb 21 '22 at 03:18
  • Thanks for your ideas but they are not applicable. I can't stop the service because it has to accept other connections with white IPs. And I don't have access to the client side because it is a web browser. For the moment I answer with HTTP error 418 I'm a teapot – Tofnet Feb 22 '22 at 09:49
  • For "HTTP error 418 I'm a teapot" you can check [this post](https://stackoverflow.com/questions/52340027/is-418-im-a-teapot-really-an-http-response-code). – Lan Huang Feb 23 '22 at 06:18

0 Answers0