提问
WebAPI如何提供下载文件功能
回答
//开启目录浏览服务
builder.Services.AddDirectoryBrowser();
//指定文件目录
app.UseFileServer(new FileServerOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(builder.Environment.ContentRootPath, "wwwroot\\UploadFiles")),
RequestPath = "/StaticFiles",
EnableDirectoryBrowsing = true
});
参考
https://learn.microsoft.com/zh-cn/aspnet/core/security/cors?view=aspnetcore-7.0
标签:WebAPI,文件,功能,builder,new,下载 From: https://www.cnblogs.com/wuhailong/p/16935319.html