I started to convert my asp.net core RC1 project to RC2 and faced with problem that now IHttpContextAccessor
does not resolved.
For sake of simplicity I
As of .NET Core 2.1 there is an extension method that has been added to correctly register an IHttpContextAccessor
as a singleton. See Add helper to register IHttpContextAccessor #947. Simply add as follows in your ConfigureServices()
method:
services.AddHttpContextAccessor();
This is equivalent to:
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
IHttpContextAccessor is no longer wired up by default, you have to register it yourself
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();