0

Possible Duplicate:
Restricting WCF Service access to only localhost

I have a WCF method set up for a .NET project.

I can enable the endpoint to work over https and / or http.

However, I only want the HTTP version (bindingConfiguration="webBinding") to work on localhost. Is there a way to restrict this in the web.config?

I had very limited success setting <endpoint address="localhost/"myproj/mysvc.svc" /> but ultimately didnt work.

Community
  • 1
  • 1
maxp
  • 24,209
  • 39
  • 123
  • 201
  • @FlorianGerhardt Which of those links shows discusses restricting it inside web.config? – maxp May 24 '12 at 11:56
  • I think that this question: "In simple way can I restrict access to SCV files using WCF configuration just to localhost?" is similar. But it looks like you have already received a response that answers your question better than the answer in the link I posted. So please ignore my commment :) – flayn May 24 '12 at 13:56

1 Answers1

3

Source: Configure WCF for LOCALHOST-only listening

Try to set the BasicHttpBinding.HostNameComparisonMode Property to HostNameComparisonMode.Exact.

or in config file..

 <bindings>
          <basicHttpBinding>
            <binding name="Binding1"
                     hostNameComparisonMode ="Exact">
              <security mode="None" />
            </binding>
          </basicHttpBinding>
    </bindings>

But better is to use the named pipe binding, which should support whatever message exchange pattern you are using (it supports request-response, as well as the same concurrency and session state modes that WS supports).

From the section of MSDN titled "Choosing a Transport"

Hope this help..

Community
  • 1
  • 1
Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75