Browse Source
Update DefaultHomePageMiddleware.cs
pull/17282/head
Enis Necipoglu
3 years ago
No known key found for this signature in database
GPG Key ID: 1EC55E13241E1680
1 changed files with
10 additions and
13 deletions
-
modules/cms-kit/src/Volo.CmsKit.Public.Web/DefaultHomePageMiddleware.cs
|
|
|
@ -16,23 +16,20 @@ public class DefaultHomePageMiddleware : IMiddleware, ITransientDependency |
|
|
|
{ |
|
|
|
var featureChecker = context.RequestServices.GetRequiredService<IFeatureChecker>(); |
|
|
|
|
|
|
|
if (!await featureChecker.IsEnabledAsync(CmsKitFeatures.PageEnable)) |
|
|
|
if (await featureChecker.IsEnabledAsync(CmsKitFeatures.PageEnable)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (context.Request.Path.Value == "/") |
|
|
|
{ |
|
|
|
var pagePublicAppService = context.RequestServices.GetRequiredService<IPagePublicAppService>(); |
|
|
|
|
|
|
|
var page = await pagePublicAppService.FindDefaultHomePageAsync(); |
|
|
|
if (page != null) |
|
|
|
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); |
|
|
|
} |
|
|
|
} |