Search code examples
c#asp.netweb-serviceswsdl

.Net - web services - Stop WSDL and default help page being accessible but leave service up


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.


Solution

  • 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>