45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace StaticFilesSample
|
|
{
|
|
public class Startup
|
|
{
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddDirectoryBrowser();
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment host)
|
|
{
|
|
Console.WriteLine("webroot: " + host.WebRootPath);
|
|
|
|
app.UseFileServer(new FileServerOptions
|
|
{
|
|
EnableDirectoryBrowsing = true
|
|
});
|
|
}
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
var host = new WebHostBuilder()
|
|
.ConfigureLogging(factory =>
|
|
{
|
|
factory.AddFilter("Console", level => level >= LogLevel.Debug);
|
|
factory.AddConsole();
|
|
})
|
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
|
.UseKestrel()
|
|
.UseIISIntegration()
|
|
.UseStartup<Startup>()
|
|
.Build();
|
|
|
|
host.Run();
|
|
}
|
|
}
|
|
}
|