1010using System ;
1111using Microsoft . AspNetCore . Builder ;
1212using Microsoft . AspNetCore . Hosting ;
13+ using Microsoft . AspNetCore . Http ;
1314using Microsoft . Extensions . PlatformAbstractions ;
1415using React . Exceptions ;
1516using React . TinyIoC ;
@@ -39,7 +40,10 @@ public static IApplicationBuilder UseReact(
3940
4041 React . AssemblyRegistration . Container . Register ( app . ApplicationServices . GetRequiredService < IHostingEnvironment > ( ) ) ;
4142
42- Initializer . Initialize ( registerOptions => AsPerRequestSingleton ( app . ApplicationServices , registerOptions ) ) ;
43+ Initializer . Initialize ( registerOptions => AsPerRequestSingleton (
44+ app . ApplicationServices . GetService < IHttpContextAccessor > ( ) ,
45+ registerOptions
46+ ) ) ;
4347 configure ( ReactSiteConfiguration . Configuration ) ;
4448
4549 // Allow serving of .jsx files
@@ -55,13 +59,13 @@ public static IApplicationBuilder UseReact(
5559 /// <param name="registerOptions">Registration options</param>
5660 /// <returns>Registration options (for chaining)</returns>
5761 private static TinyIoCContainer . RegisterOptions AsPerRequestSingleton (
58- IServiceProvider appServiceProvider ,
62+ IHttpContextAccessor httpContextAccessor ,
5963 TinyIoCContainer . RegisterOptions registerOptions
6064 )
6165 {
6266 return TinyIoCContainer . RegisterOptions . ToCustomLifetimeManager (
6367 registerOptions ,
64- new HttpContextLifetimeProvider ( appServiceProvider ) ,
68+ new HttpContextLifetimeProvider ( httpContextAccessor ) ,
6569 "per request singleton"
6670 ) ;
6771 }
0 commit comments