在啓動文件中添加如下配置 app
public class Startup { public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddDirectoryBrowser(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(ApplicationEnvironments.BaseDirectory.Replace("SystemCloud\\", ""), @"SystemCloud") ), RequestPath = new PathString("/static/cloud"), OnPrepareResponse = ctx => { ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600"); } }); app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(ApplicationEnvironments.BaseDirectory.Replace("SystemCloud\\", ""), @"SystemCloud")), RequestPath = new PathString("/static/cloud"), }); } }