.Net异常:The Web server is configured to not list the contents of this directory.

阅文时长 | 0.76分钟 字数统计 | 1231.2字符
主要内容 | 1、引言&背景 2、解决方案 3、声明与参考资料
『.Net异常:The Web server is configured to not list the contents of this directory.』
编写人 | SCscHero 编写时间 | 2022/2/5 PM4:53
文章类型 | 系列 完成度 | 已完成
座右铭 每一个伟大的事业,都有一个微不足道的开始。

一、引言&背景   完成度:100%

a) 应对问题

在修改了Debug > General > "Open debug launch profies UI" > IIS Express > App URL的设置后。发现原来可用的Swagger路由跳转变得不可用了,把App URL的设置还原后还是不可用。代码没有任何修改,只动过启动URL。

.Net异常:The Web server is configured to not list the contents of this directory.

详细异常如下:

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.

Things you can try:
If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.
Enable directory browsing.
Go to the IIS Express install directory.
Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the server level.
Run appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the site level.
Verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.

Detailed Error Information:
Module	   DirectoryListingModule
Notification	   ExecuteRequestHandler
Handler	   StaticFile
Error Code	   0x00000000
Requested URL	   https://localhost:44345/swagger/
Physical Path	   C:\LIST.MeGitCloud List\UFQI_015_SCscBlogMSAPP\
Logon Method	   Anonymous
Logon User	   Anonymous

More Information:
This error occurs when a document is not specified in the URL, no default document is specified for the Web site or application, and directory listing is not enabled for the Web site or application. This setting may be disabled on purpose to secure the contents of the server.
View more information "

.Net异常:The Web server is configured to not list the contents of this directory.

且会造成一系列连锁异常反应。

b) 应用场景

  • 使用VisualStudio的IDE,且更改过App URL的设置。
  • 使用IIS的启动方式。

二、解决方案   完成度:100%

最终RootCause为VS或IIS的BUG。删除.vs[AppName]\config\applicationhost.config文件即可。

三、声明与参考资料   完成度:100%

原创博文,未经许可请勿转载。

如有帮助,欢迎点赞、收藏、关注。如有问题,请评论留言!如需与博主联系的,直接博客私信SCscHero即可。

上一篇:vue2后台动态路由


下一篇:06 路飞组件实施和git的使用