Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

IHttpContextAccessor

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>();
Comment

PREVIOUS NEXT
Code Example
Csharp :: increase value in dictionary against a key in c# 
Csharp :: use slider in unity 
Csharp :: check property type of collection c# 
Csharp :: convert decimal to 2 decimal places c# 
Csharp :: limiting the amount of decimal places c# 
Csharp :: how to remove all whitespace from a string in c# 
Csharp :: how to change dictionary value in c# 
Csharp :: checking a gamobjects layer 
Csharp :: unity get gameobject from hit 
Csharp :: c# picturebox transparente 
Csharp :: Read a Word Document Using C# 
Csharp :: comments in c# 
Csharp :: unity gui style color button 
Csharp :: pyautopgui erros 
Csharp :: how to skip bin/Debug/netcoreapp3.1/ on the reltaive path 
Csharp :: c# code to read txt file line by line and split 
Csharp :: c# wpf timer 
Csharp :: what value of combobox index c# 
Csharp :: how to store some variables on the device in unity 
Csharp :: authentication and authorization in asp.net c# with example 
Csharp :: how to close another app in system with c# 
Csharp :: c# override gethashcode 
Csharp :: C# trim trailing zero 
Csharp :: c# get distinct values all fields from list 
Csharp :: window height in C# forms 
Csharp :: interface property implementation c# 
Csharp :: unity c# move transform 
Csharp :: C# get column of 2d array 
Csharp :: mvc c# return renderPartial 
Csharp :: how to sign in with your unity id in unity hub 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =