Home > front end >  kestrel serve static file starting with a dot
kestrel serve static file starting with a dot

Time:08-28

kestrel (net5.0-windows) is configured to serve static files and allow directory browsing for a non-bare git repository:

services.AddDirectoryBrowser();

var requestPath = "";
var fileProvider = new PhysicalFileProvider(@"D:\MyGitRepo");

app.UseStaticFiles(new StaticFileOptions { FileProvider = fileProvider, RequestPath = requestPath, ServeUnknownFileTypes = true, });
app.UseDirectoryBrowser(new DirectoryBrowserOptions { FileProvider = fileProvider, RequestPath = requestPath });

.UseWebRoot(@"D:\MyGitRepo")
.UseContentRoot(@"D:\MyGitRepo")

the directory browser does not show the .git folder and the .gitignore file is not found, how to resolve this issue?

CodePudding user response:

You can configure it by using PhysicalFileProvider constructor's second parameter:

using Microsoft.Extensions.FileProviders.Physical;
...
...
var fileProvider = new PhysicalFileProvider(@"D:\MyGitRepo", ExclusionFilters.None);
  • Related