qinchulong
2025-03-29 039a4a5433e7f80adc88b491b549e5d9486e4f9a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.FileProviders;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
 
namespace WIDESEA_Core.Extensions
{
    public static class StaticDefaultFileExtensions
    {
        public static IApplicationBuilder UseStaticDefaultFile(this IApplicationBuilder app, string path)
        {
            app.UseStaticFiles(new StaticFileOptions()
            {
 
                FileProvider = new PhysicalFileProvider(
                Path.Combine(path, "Content")),
                RequestPath = new PathString("/Content")
                //,
                //OnPrepareResponse = x => {
                //    x.Context.Response.Headers.Append("Cache-Control", "public,max-age=600");
                //}
            })
            .UseStaticFiles(new StaticFileOptions()
            {
 
                FileProvider = new PhysicalFileProvider(
                Path.Combine(path, "fonts")),
                RequestPath = new PathString("/fonts")
            })
            .UseStaticFiles(new StaticFileOptions()
            {
 
                FileProvider = new PhysicalFileProvider(
                Path.Combine(path, "Scripts")),
                RequestPath = new PathString("/Scripts")
            })
            .UseStaticFiles(new StaticFileOptions()
            {
 
                FileProvider = new PhysicalFileProvider(
                Path.Combine(path, "Html")),
                RequestPath = new PathString("/Html")
            });
            return app;
        }
    }
}