From 88382b76636b01c867ed629b776cce776a48e9ba Mon Sep 17 00:00:00 2001 From: iioter <535915157@qq.com> Date: Thu, 9 Nov 2023 19:33:51 +0800 Subject: [PATCH] ServeUnknownFileTypes --- IoTGateway/Startup.cs | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/IoTGateway/Startup.cs b/IoTGateway/Startup.cs index d390cd7..a393773 100644 --- a/IoTGateway/Startup.cs +++ b/IoTGateway/Startup.cs @@ -84,31 +84,11 @@ namespace IoTGateway public void Configure(IApplicationBuilder app, IOptionsMonitor configs, DeviceService deviceService, ModbusSlaveService modbusSlaveService) { IconFontsHelper.GenerateIconFont(); - - var pvd = new StaticFileOptions + app.UseExceptionHandler(configs.CurrentValue.ErrorHandler); + app.UseStaticFiles(new StaticFileOptions() { - FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot")), - RequestPath = new PathString(""), - //设置不限制content-type 该设置可以下载所有类型的文件,但是不建议这么设置,因为不安全 - //下面设置可以下载apk和nupkg类型的文件 - ContentTypeProvider = new FileExtensionContentTypeProvider(new Dictionary - { - { ".html", "text/html" }, - { ".glb", "model/gltf-binary" }, - { ".json", " application/json" }, - { ".js", "application/javascript" }, - { ".css", "text/css" }, - { ".wasm", "application/wasm" }, - { ".png", "image/png" }, - { ".jpg", "image/jpg" }, - { ".woff", "application/font-woff" }, - { ".woff2", "application/font-woff" }, - { ".ico", "image/x-icon" }, - }) - }; - - app.UseExceptionHandler(configs.CurrentValue.ErrorHandler); - app.UseStaticFiles(pvd); + ServeUnknownFileTypes = true + }); app.UseWtmStaticFiles(); app.UseRouting(); app.UseWtmMultiLanguages();