In ASP.NET Core RC 1 I used the following code to retrieve the value of context (full address of the page). Then I recorded this value in the configuration.
p
You can add in this way.
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
It is no longer a default service. You have to configure it in Startup.cs
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();
UPDATE: In ASP.NET Core 2.1, the AddHttpContextAccessor helper extension method was added to correctly register the IHttpContextAccessor
with the correct lifetime (singleton). So, in ASP.NET Core 2.1 and above, the code should be
services.AddHttpContextAccessor();
services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();
Source: https://github.com/aspnet/Hosting/issues/793