Browse Source

Merge pull request #15475 from abpframework/EngincanV/cms-kit

CmsKit: Performance Improvements on DefaultHomePageMiddleware
pull/15478/head
Enis Necipoglu 4 years ago
committed by GitHub
parent
commit
0848e279ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      modules/cms-kit/src/Volo.CmsKit.Public.Web/DefaultHomePageMiddleware.cs

13
modules/cms-kit/src/Volo.CmsKit.Public.Web/DefaultHomePageMiddleware.cs

@ -12,11 +12,16 @@ public class DefaultHomePageMiddleware : IMiddleware, ITransientDependency
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
var _pagePublicAppService = context.RequestServices.GetRequiredService<IPagePublicAppService>();
var page = await _pagePublicAppService.FindDefaultHomePageAsync();
if (page is not null && context.Request.Path.Value == "/")
if (context.Request.Path.Value == "/")
{
context.Request.Path = $"{PageConsts.UrlPrefix}{page.Slug}";
var pagePublicAppService = context.RequestServices.GetRequiredService<IPagePublicAppService>();
var page = await pagePublicAppService.FindDefaultHomePageAsync();
if (page != null)
{
context.Request.Path = $"{PageConsts.UrlPrefix}{page.Slug}";
}
}
await next(context);

Loading…
Cancel
Save