Search code examples
c#wcfiis

IIS showing files in browser. How do I prevent this?


My api is here: http://ip/myapi.svc.

If I call http://myip, the browser displays some files from the server.

enter image description here

What can I do to prevent this?

I'm using IIS 8.5 running on Windows Server 2012 R2.


Solution

  • This has nothing to do with your WCF Service. Your current IIS Configurations allows Directory Listing.

    To disable it you can use the IIS Manager and then choose whether you want to disable it on site level or machine level.

    After you've chosen the website or the the Server Choose (Directory Browsing) and on the right pane click disable.

    Edit:

    You can also disable directory listing from Web.config as shown in this answer

    but I'm not sure if it will work with IIS 6