views:

27

answers:

2

Hi, I have a simple .Net web service. When I visit the /webservice.svc path in a browser .Net renders a nice help page with some sample C# and VB.Net code. How do I stop this from displaying? Also, is there any way to prevent a request for ?wsdl from returning the wsdl file?

Thanks for any insight in advance.

+2  A: 

Remove <serviceMetadata httpGetEnabled="true"/> from web.config

<system.serviceModel>
            ...
    <behaviors>
        <serviceBehaviors>
            <behavior name="mexBehavior">
                <!-- Remove this 
                    <serviceMetadata httpGetEnabled="true"/> 
                 -->
                <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>
Per-Frode Pedersen
Thanks, this removes both wsdl access and help content
frimley
Indeed. I should have said so in my answer, thank you for pointing it out.
Per-Frode Pedersen
A: 

For IIS6, use the following to disable the WSDL:

  <system.web>
    <webServices>
      <protocols>
        <remove name="Documentation"/>
      </protocols>
    </webServices>
  </system.web>
kbrimington