Browse Source

Merge pull request #18922 from abpframework/issue-18447

Index url controls added
pull/18960/head
oykuermann 3 years ago
committed by GitHub
parent
commit
3889c63c09
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 32
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

32
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
@ -117,18 +117,32 @@ namespace Volo.Docs.Pages.Documents.Project
{ {
return Redirect(decodedUrl); return Redirect(decodedUrl);
} }
try var documentPath = DocumentName ?? "";
string[] documentNames;
if (displayUrl.EndsWith("/index", StringComparison.OrdinalIgnoreCase))
{ {
return await SetPageAsync(); documentPath = documentPath.Substring(0, documentPath.LastIndexOf('/') + 1);
} }
catch (DocumentNotFoundException exception)
{
Logger.LogWarning(exception.Message);
DocumentFound = false; documentNames = new[] { DocumentName, documentPath.EnsureEndsWith('/') + "Index", documentPath.EnsureEndsWith('/') + "index" };
Response.StatusCode = 404;
return Page(); foreach (var documentName in documentNames)
{
DocumentName = documentName;
try
{
return await SetPageAsync();
}
catch (DocumentNotFoundException exception)
{
Logger.LogWarning(exception.Message);
}
} }
DocumentFound = false;
Response.StatusCode = 404;
return Page();
} }
private async Task<IActionResult> SetPageAsync() private async Task<IActionResult> SetPageAsync()

Loading…
Cancel
Save