diff --git a/src/docs-builder/Http/DocumentationWebHost.cs b/src/docs-builder/Http/DocumentationWebHost.cs index 1d2fe4f03..ca55d1545 100644 --- a/src/docs-builder/Http/DocumentationWebHost.cs +++ b/src/docs-builder/Http/DocumentationWebHost.cs @@ -178,12 +178,14 @@ private static async Task ServeDocumentationFile(ReloadableGeneratorSta case ImageFile image: return Results.File(image.SourceFile.FullName, image.MimeType); default: - if (generator.DocumentationSet.FlatMappedFiles.TryGetValue("404.md", out var notFoundDocumentationFile)) - { - var renderedNotFound = await generator.RenderLayout((notFoundDocumentationFile as MarkdownFile)!, ctx); - return Results.Content(renderedNotFound, "text/html", null, (int)HttpStatusCode.NotFound); - } - return Results.NotFound(); + if (s == "index.md") + return Results.Redirect(generator.DocumentationSet.MarkdownFiles.First().Value.Url); + + if (!generator.DocumentationSet.FlatMappedFiles.TryGetValue("404.md", out var notFoundDocumentationFile)) + return Results.NotFound(); + + var renderedNotFound = await generator.RenderLayout((notFoundDocumentationFile as MarkdownFile)!, ctx); + return Results.Content(renderedNotFound, "text/html", null, (int)HttpStatusCode.NotFound); } } }