.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。

詳細異常如下:

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 "

且會造成一系列連鎖異常反應。

b) 應用場景

  • 使用VisualStudio的IDE,且更改過App URL的設置。
  • 使用IIS的啟動方式。

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

最終RootCause為VS或IIS的BUG。刪除.vs[AppName]\config\applicationhost.config文件即可。

三、聲明與參考資料   完成度:100%

原創博文,未經許可請勿轉載。

如有幫助,歡迎點贊、收藏、關注。如有問題,請評論留言!如需與博主聯系的,直接博客私信SCscHero即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM