Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devise solution for IHostedService and service provider/HttpContext #1844

Open
rockfordlhotka opened this issue Oct 14, 2020 · 5 comments
Open

Comments

@rockfordlhotka
Copy link
Member

As per #1831, a IHostedService doesn't get access to HttpContext, and thus LocalContext (containing the DI service provider) doesn't flow from ASP.NET into a service.

@dazinator
Copy link
Member

dazinator commented Oct 27, 2020

I have commented on #1831 with my (a) solution as per the year 2017.
One thing I noticed is that CslaConfiguration doesn't expose an option to configure WebContextManager only ContextManager and my solution did rely on being able to set both context managers. We can still directly set it via Csla.ApplicationContext.WebContextManager - however would accept a PR to add this to CslaConfiguration ?

Note: I see its there, but it doesn't light up within .netcoreapp3.1 project, for example this is inside the Blazor.Server sample project inside this repo:

image

@dazinator
Copy link
Member

As of #1876 this scenario should be possible, by the background job creating a DI scope and setting the csla scoped provider. Not sure how this information should be surfaced - perhaps we should add some tests for this scenario to the asp.net core test suite.

@rockfordlhotka
Copy link
Member Author

I don't believe there are currently any ASP.NET Core "unit tests" - at least not that require that the CI server host a web server.

@dazinator
Copy link
Member

Asp.net core ships a TestHost for this. Would you be open to having some tests that exercise csla within a few asp.net core scenarios? I am thinking:

  • test that uses csla within an aspnet core middleware (i.e so in scope with a current request)
  • test that uses csla from an IHostedService (out of scope from a request)

https://adamstorr.azurewebsites.net/blog/integration-testing-with-aspnetcore-3-1

@rockfordlhotka
Copy link
Member Author

Yes, I think that would be a good addition to the test suite!

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

No branches or pull requests

2 participants