13
13
using Umbraco . Cms . Core . Events ;
14
14
using Umbraco . Cms . Core . Hosting ;
15
15
using Umbraco . Cms . Core . Logging ;
16
+ using Umbraco . Cms . Core . Models . PublishedContent ;
16
17
using Umbraco . Cms . Core . Notifications ;
18
+ using Umbraco . Cms . Core . PublishedCache ;
17
19
using Umbraco . Cms . Core . Routing ;
18
20
using Umbraco . Cms . Core . Scoping ;
19
- using Umbraco . Cms . Core . Security ;
20
21
using Umbraco . Cms . Core . Services ;
21
22
using Umbraco . Cms . Core . Web ;
22
23
using Umbraco . Cms . Infrastructure . PublishedCache ;
@@ -50,6 +51,8 @@ public class UmbracoRequestMiddleware : IMiddleware
50
51
private readonly UmbracoRequestPaths _umbracoRequestPaths ;
51
52
private readonly BackOfficeWebAssets _backOfficeWebAssets ;
52
53
private readonly IRuntimeState _runtimeState ;
54
+ private readonly IVariationContextAccessor _variationContextAccessor ;
55
+ private readonly IDefaultCultureAccessor _defaultCultureAccessor ;
53
56
private readonly SmidgeOptions _smidgeOptions ;
54
57
private readonly WebProfiler _profiler ;
55
58
@@ -77,7 +80,9 @@ public UmbracoRequestMiddleware(
77
80
UmbracoRequestPaths umbracoRequestPaths ,
78
81
BackOfficeWebAssets backOfficeWebAssets ,
79
82
IOptions < SmidgeOptions > smidgeOptions ,
80
- IRuntimeState runtimeState )
83
+ IRuntimeState runtimeState ,
84
+ IVariationContextAccessor variationContextAccessor ,
85
+ IDefaultCultureAccessor defaultCultureAccessor )
81
86
{
82
87
_logger = logger ;
83
88
_umbracoContextFactory = umbracoContextFactory ;
@@ -88,6 +93,8 @@ public UmbracoRequestMiddleware(
88
93
_umbracoRequestPaths = umbracoRequestPaths ;
89
94
_backOfficeWebAssets = backOfficeWebAssets ;
90
95
_runtimeState = runtimeState ;
96
+ _variationContextAccessor = variationContextAccessor ;
97
+ _defaultCultureAccessor = defaultCultureAccessor ;
91
98
_smidgeOptions = smidgeOptions . Value ;
92
99
_profiler = profiler as WebProfiler ; // Ignore if not a WebProfiler
93
100
}
@@ -110,6 +117,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
110
117
111
118
EnsureContentCacheInitialized ( ) ;
112
119
120
+ _variationContextAccessor . VariationContext ??= new VariationContext ( _defaultCultureAccessor . DefaultCulture ) ;
113
121
UmbracoContextReference umbracoContextReference = _umbracoContextFactory . EnsureUmbracoContext ( ) ;
114
122
115
123
Uri currentApplicationUrl = GetApplicationUrlFromCurrentRequest ( context . Request ) ;
0 commit comments