c# - Using HttpContextAccessor in a .NET 4.6 project -


i've created .net core project (a class library) targets .net 4.6, needs able access current http context. see can no longer use static httpcontext.current, , have inject instance of ihttpcontextaccessor. can still use inside web api project targeting .net 4.6? far, can't httpcontextaccessor.httpcontext return null.

for class library think might want pass relevant variables/objects via constructor or methods. it's practice, because class library wont break if reference in console app without httpcontext, example.

if you're inside controller method, can use request or response.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -