Skip to content
Discussion options

You must be logged in to vote

OK, so from what I can find (such as https://forums.asp.net/t/2144171.aspx?Access+HttpContext+in+HostedService) the HttpContext is not supposed to be available to any IHostedService. Apparently that's a design choice in ASP.NET.

It looks like such a service should be registered as a transient service, and any services it requires should be injected into the service: dotnet/extensions#553

I think the issue with the data portal is that it is using an API to invoke dependency injection based on the service provider captured in Startup.cs - and that should be fine - except that the service provider instance is stored in ApplicationContext.LocalContext, and that (in turn) is stored in HttpContext

Replies: 5 comments 27 replies

Comment options

You must be logged in to vote
3 replies
@skeeler88
Comment options

@rockfordlhotka
Comment options

@skeeler88
Comment options

Comment options

You must be logged in to vote
3 replies
@skeeler88
Comment options

@rockfordlhotka
Comment options

@skeeler88
Comment options

Answer selected by skeeler88
Comment options

You must be logged in to vote
14 replies
@dazinator
Comment options

@rockfordlhotka
Comment options

@rockfordlhotka
Comment options

@rockfordlhotka
Comment options

@dazinator
Comment options

Comment options

You must be logged in to vote
1 reply
@rockfordlhotka
Comment options

Comment options

You must be logged in to vote
6 replies
@rockfordlhotka
Comment options

@rockfordlhotka
Comment options

@rockfordlhotka
Comment options

@dazinator
Comment options

@rockfordlhotka
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants