Configure 添加代码如下:
//这种是通过请求具体的文件 app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Log") ), RequestPath = new PathString("/MyLog") }); //通过浏览器访问项目下的文件夹 app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Log") ), RequestPath = new PathString("/MyLog") });
ConfigureServices添加代码如下:
services.AddDirectoryBrowser();
访问对应的Url
http://localhost:13387/MyLog/
结果