Browse Source

Merge branch 'abpframework:dev' into dev

pull/17129/head
Masood Khoshgard 3 years ago
committed by GitHub
parent
commit
70714cd61d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      modules/cms-kit/src/Volo.CmsKit.Public.Web/DefaultHomePageMiddleware.cs

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

@ -3,6 +3,8 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Features;
using Volo.CmsKit.Features;
using Volo.CmsKit.Pages; using Volo.CmsKit.Pages;
using Volo.CmsKit.Public.Pages; using Volo.CmsKit.Public.Pages;
@ -12,18 +14,22 @@ public class DefaultHomePageMiddleware : IMiddleware, ITransientDependency
{ {
public async Task InvokeAsync(HttpContext context, RequestDelegate next) public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{ {
if (context.Request.Path.Value == "/") var featureChecker = context.RequestServices.GetRequiredService<IFeatureChecker>();
if (await featureChecker.IsEnabledAsync(CmsKitFeatures.PageEnable))
{ {
var pagePublicAppService = context.RequestServices.GetRequiredService<IPagePublicAppService>(); if (context.Request.Path.Value == "/")
var page = await pagePublicAppService.FindDefaultHomePageAsync();
if (page != null)
{ {
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); await next(context);
} }
} }
Loading…
Cancel
Save