lith hace 5 años
padre
commit
8c92f85c64

+ 24 - 1
dotnet/Vit/Vit.WebHost/Extensions/IApplicationBuilderExtensions_UseStaticFiles.cs

@@ -1,5 +1,6 @@
 using Microsoft.AspNetCore.Builder;
 using Microsoft.Extensions.FileProviders;
+using System.Collections.Generic;
 using Vit.WebHost;
 
 namespace Vit.Extensions
@@ -46,7 +47,29 @@ namespace Vit.Extensions
                 staticfileOptions.ContentTypeProvider = config.contentTypeProvider;
             }
 
-            data.UseStaticFiles(staticfileOptions);          
+
+
+            #region (x.6)UseDefaultFiles
+            if (config.defaultFileNames != null) 
+            {
+                data.UseDefaultFiles(new DefaultFilesOptions
+                {
+                    DefaultFileNames = config.defaultFileNames
+                });
+            }
+            #endregion
+
+
+            //(x.7)UseStaticFiles
+            data.UseStaticFiles(staticfileOptions);
+
+
+            //(x.8)UseDirectoryBrowser
+            if (config.useDirectoryBrowser == true) 
+            {               
+                data.UseDirectoryBrowser(new DirectoryBrowserOptions { FileProvider = staticfileOptions.FileProvider });
+            }
+
 
             return data;
         }

+ 15 - 0
dotnet/Vit/Vit.WebHost/StaticFilesConfig.cs

@@ -43,6 +43,21 @@ namespace Vit.WebHost
         #endregion
 
 
+        /// <summary>
+        /// 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance
+        /// </summary>       
+        [JsonProperty]
+        public List<string> defaultFileNames { get; set; }
+
+
+        /// <summary>
+        /// 是否可浏览目录(default false)。Enables directory browsing
+        /// </summary>       
+        [JsonProperty]
+        public bool? useDirectoryBrowser { get; set; }
+
+
+
         /// <summary>
         /// 回应静态文件时额外添加的http回应头。可不指定。
         /// </summary>       

+ 6 - 0
dotnet/netcore/Gateway/App.Gateway/appsettings.json

@@ -71,6 +71,12 @@
           /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
           "rootPath": "wwwroot",
 
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          //"defaultFileNames": [],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
+
           /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
           "contentTypeMapFile": "contentTypeMap.json",
 

+ 7 - 1
dotnet/netcore/ServiceCenter/App.Gover.Gateway/appsettings.json

@@ -64,7 +64,13 @@
         "staticFiles": {
 
           /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
-          "rootPath": "wwwroot",
+          //"rootPath": "wwwroot",
+
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          //"defaultFileNames": [],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
 
           /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
           "contentTypeMapFile": "contentTypeMap.json",

+ 7 - 1
dotnet/netcore/ServiceCenter/App.ServiceCenter/appsettings.json

@@ -328,7 +328,13 @@
         "staticFiles": {
 
           /* 静态文件路径。可为相对路径或绝对路径。若为空或空字符串则默认为入口程序所在目录下的wwwroot文件夹。demo:"wwwroot/demo" */
-          "rootPath": "wwwroot",
+          //"rootPath": "wwwroot",
+
+          /* 默认页面(可不指定)。An ordered list of file names to select by default. List length and ordering  may affect performance */
+          //"defaultFileNames": [],
+
+          /* 是否可浏览目录(default false)。Enables directory browsing */
+          //"useDirectoryBrowser": false,
 
           /* 静态文件类型映射配置的文件路径。可为相对路径或绝对路径。例如"contentTypeMap.json"。若不指定(或指定的文件不存在)则不指定文件类型映射配置 */
           "contentTypeMapFile": "contentTypeMap.json",