Add basic setup for static files
This commit is contained in:
parent
4f4075c8f4
commit
b6fc17b48b
@ -30,6 +30,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="WebServer\App" />
|
||||
<Folder Include="wwwroot\src" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@ -36,7 +37,6 @@ namespace ChaosBot.WebServer
|
||||
{
|
||||
_logger.Info("Initializing Kestrel Startup and Configuration");
|
||||
|
||||
|
||||
if (Program.AppSettingsHandler.GetValue<bool>("WebServer:Debug", false))
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
@ -45,6 +45,12 @@ namespace ChaosBot.WebServer
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
||||
|
||||
DefaultFilesOptions options = new DefaultFilesOptions();
|
||||
options.DefaultFileNames.Clear();
|
||||
options.DefaultFileNames.Add("index.html");
|
||||
app.UseDefaultFiles(options);
|
||||
app.UseStaticFiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
@ -19,6 +20,11 @@ namespace ChaosBot.WebServer
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
string contentRoot = Directory.GetCurrentDirectory();
|
||||
string webRoot = Path.Combine(contentRoot, "wwwroot");
|
||||
|
||||
webBuilder.UseContentRoot(contentRoot);
|
||||
webBuilder.UseWebRoot(webRoot);
|
||||
webBuilder.ConfigureKestrel(serverOptions =>
|
||||
{
|
||||
serverOptions.Listen(IPAddress.Any, Program.AppSettingsHandler.GetValue<int>("WebServer:Port"),
|
||||
|
||||
13
ChaosBot/wwwroot/index.html
Normal file
13
ChaosBot/wwwroot/index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Index</h2>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user