设置后,wwwroot下面的文件及子文件夹中的文件都可以下载  

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {

       app.UseStaticFiles(new StaticFileOptions()
            {
                ServeUnknownFileTypes = true,
                FileProvider = new PhysicalFileProvider(
                Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")),//wwwroot相当于真实目录
                RequestPath = new PathString("/src") //src相当于别名,为了安全
            });

}

.netcore3.1 访问静态文件,如图片、Excel等

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2021-09-08
  • 2021-11-09
猜你喜欢
  • 2021-12-04
  • 2021-05-19
  • 2021-06-21
  • 2021-07-15
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案