Is it possible to serve static files from outside the wwwroot folder?

落爺英雄遲暮 提交于 2019-12-04 02:52:27
David Driscoll

You can set the file provider on the options object when using the middleware.

app.UseStaticFiles(new StaticFileOptions() {
    FileProvider = new PhysicalFileProvider(@"C:\Path\To\Files"),
    RequestPath = new PathString("/somepath")
})

See: https://github.com/aspnet/StaticFiles/blob/master/src/Microsoft.AspNetCore.StaticFiles/Infrastructure/SharedOptions.cs#L44

and

https://github.com/aspnet/FileSystem/blob/dev/src/Microsoft.Extensions.FileProviders.Physical/PhysicalFileProvider.cs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!