18

Cassini (Visual Studio development web server) by default enables directory browsing, how can I enable directory browsing on IIS Express by default? (I don't want to have a separate configuration for each project I have?

Ahmed Magdy
  • 5,256
  • 8
  • 36
  • 74

4 Answers4

25
  1. Go to Web.config file of your project.

  2. Add the below two tags in <system.webServer> tag in web.config

<directoryBrowse enabled="true" />

<modules runAllManagedModulesForAllRequests="true" />

Chad Levy
  • 9,659
  • 7
  • 38
  • 66
Moni
  • 251
  • 3
  • 2
  • 1
    This one worked for me for Visual Studio 2017 (info! do not forget to create tags in web.config, because they are not there) – Erdinc Ay Sep 07 '17 at 08:09
  • Thanks!! This saved my day. Worked for me Visual Studio 2017. – luckyShubhra Sep 16 '17 at 09:05
  • @Moni: Can you advise little more on your answer? After adding advised elements in web.config my web api application listed directory structure. Should not it had run with a default controller at first place? – Binoy Sep 07 '18 at 21:16
20

You should be able to use AppCmd.exe to manage IIS Express. Try this:

appcmd set config /section:directoryBrowse /enabled:true

More info on AppCmd.exe here: http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe

Michael Cox
  • 1,233
  • 13
  • 14
  • 3
    Be an admin run this %systemroot%\system32\inetsrv\appcmd set config /section:directoryBrowse /enabled:true – Mickey Perlstein Aug 16 '12 at 09:48
  • 7
    I had to run the copy of appcmd that lived in `%programFiles(x86)%\IIS Express\` . If I ran the other copy, the setting would not take. I guess I have 2 versions of IIS installed. http://forums.iis.net/post/1993018.aspx – Walter Stabosz Feb 18 '14 at 16:11
  • 1
    @WalterStabosz Thanks for that comment. I got this to work, by following your comment. – abhi Apr 28 '14 at 12:56
  • `ERROR ( hresult:80070020, message:Failed to commit configuration changes. The process cannot access the file because it is being used by another process.` – Junior Mayhé Aug 09 '18 at 19:47
6

you can use appcmd tool

APPCMD (command) (object-type) <identifier> < /parameter1:value1 ... >*

Where is one of the commands supported by .Most objects support this basic set of commands:

LIST Display the objects on the machine. An optional can specify a unique object to list, or one or more parameters can be specified to match against object properties.

ADD Create a new object with the specified object properties to set during creation.

DELETE Delete the object specified by the .

SET Set parameters on the object specified by .

Enable directory browsing.

Go to the IIS Express install directory.

1: Enable directory browsing at the server level

Run `appcmd set config /section:system.webServer/directoryBrowse /enabled:true`

2: Enable directory browsing at the site level

Run `appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true`

Note: Run with elevated permission

you can verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.

Reference : IIS

JackArbiter
  • 5,435
  • 2
  • 24
  • 31
joshua
  • 2,373
  • 2
  • 26
  • 54
2

for those coming across this years later: directory browsing can also be enabled via IIS Manager:

IIS Manager Directory Browsing

David Walschots
  • 10,733
  • 5
  • 33
  • 53