Static site hosting support access directory as index.html

This commit is contained in:
2025-11-22 15:49:29 +08:00
parent ef02265ccd
commit 2b56c6f1e5

View File

@@ -63,6 +63,17 @@ public class PublicationSiteMiddleware(RequestDelegate next)
return; return;
} }
if (Directory.Exists(hostedFilePath))
{
var indexPath = Path.Combine(hostedFilePath, "index.html");
if (File.Exists(indexPath))
{
context.Response.ContentType = "text/html";
await context.Response.SendFileAsync(indexPath);
return;
}
}
var hostedNotFoundPath = psm.GetValidatedFullPath(site.Id, "404.html"); var hostedNotFoundPath = psm.GetValidatedFullPath(site.Id, "404.html");
if (File.Exists(hostedNotFoundPath)) if (File.Exists(hostedNotFoundPath))
{ {