I've setup static files and directory browsing like this:
PhysicalFileProvider physicalFileProvider = new PhysicalFileProvider(somePath, ExclusionFilters.None);
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = physicalFileProvider,
RequestPath = "/files",
ServeUnknownFileTypes = true
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(somePath),
RequestPath = "/files"
});
I've been searching documentation and browsing through object models but I can't figure out how to set the include and exclude filters. My current code is filtering files starting with . (hidden? but I'm running on Windows ) I want to show and download these files but hide other types such as *.json and web.config.
app.UseWhen()>to judge the request if ends with .json to use the static file middleware. But if you also want to limit browsering file type byUseDirectoryBrowser, maybe you need customPhysicalFileProvider.