Disabling Web Services Documentation (Protocol) for ASP.Net Web Services

When you create a web site that uses web services for asynchronous jobs etc., your services documentation is publicly available to anyone. A web service documentation generally looks like below:

Let's say you have a service class called “recordThis.cs”, under App_Code folder. Anybody can get the documentation for this class by going to “yourwebsite.com/ recordThis.asmx”.

For security reasons you may not want this documentation to be available to the users of your web site and there is a simple procedure to achieve this, which is basically editing the web.config file.

Web.config file is a magical configuration file for ASP.Net web sites and applications, and for this job we'll configure this file as below:

1- Open web.config file using Visual Studio or a simple text editor
2- Add the lines below somewhere between <system.web>…</system.web> tags


        <remove name="Documentation"/> 

3- Save web.config file

Now try opening the documentation for your web services. You should be getting an error message, meaning they are no longer accessable. You can add a custom error page to handle this beautifully.

Hope this helps someone.

Good luck,

Leave a Reply

Your email address will not be published. Required fields are marked *