WebAPI如何提供下载文件功能
提问
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

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号