默认情况下,Cassini(Visual Studio开发Web服务器)启用目录浏览。那么,我该如何在IIS Express上默认启用目录浏览呢?(我不想为每个项目单独配置)?
请注意保留原有的HTML标签格式。
请注意保留原有的HTML标签格式。
打开您的项目中的Web.config
文件。
在web.config
文件中的<system.webServer>
标签中添加以下两个标签:
<directoryBrowse enabled="true" />
<modules runAllManagedModulesForAllRequests="true" />
你可以使用AppCmd.exe来管理IIS Express。试试这个:
appcmd set config /section:directoryBrowse /enabled:true
在此处获取有关AppCmd.exe的更多信息: http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe
%programFiles(x86)%\IIS Express\
中的 appcmd 副本。如果我运行另一个副本,则设置将不会生效。我猜我安装了两个版本的 IIS。http://forums.iis.net/post/1993018.aspx - Walter StaboszERROR ( hresult:80070020, message:Failed to commit configuration changes. The process cannot access the file because it is being used by another process.
- Junior Mayhéappcmd
工具。APPCMD (command) (object-type) <identifier> < /parameter1:value1 ... >*
其中之一命令是。大多数对象都支持这些基本命令:
LIST 显示机器上的对象。可选的 可以指定要列出的唯一对象,也可以指定一个或多个参数来匹配对象属性。
ADD 创建一个新对象,并在创建过程中设置指定的对象属性。
DELETE 删除被指定的对象。
SET 设置被指定对象的参数。
启用目录浏览。
转到 IIS
Express 安装目录。
1: 在服务器级别上启用目录浏览
Run `appcmd set config /section:system.webServer/directoryBrowse /enabled:true`
2:在站点级别启用目录浏览
Run `appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true`
注意:需要具备管理员权限运行。
您可以验证站点或应用程序配置文件中的configuration/system.webServer/directoryBrowse@enabled属性是否设置为true。
参考文献:IIS