public void ConfigureServices(IServiceCollection services)
{
services.AddDirectoryBrowser();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
var dir =new DirectoryBrowserOptions();
dir.FileProvider = new PhysicalFileProvider(@"E:");
app.UseDirectoryBrowser(dir);
var sta = new StaticFileOptions();
sta.FileProvider = new PhysicalFileProvider(@"E:");
sta.ServeUnknownFileTypes = true;
sta.DefaultContentType = "application/x-msdownload";
var pro = new FileExtensionContentTypeProvider();
pro.Mappings.Add(".log","text/plain");
sta.ContentTypeProvider = pro;
app.UseStaticFiles(sta);
}
//手机局域网访问
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseUrls("http://*:5000")
.UseStartup<Startup>()
.Build();
host.Run();
}