-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Consider adding services.AddHttpContextAccessor() to AddAspNetCore() #4487
Comments
I thought about that too, but was concerned that this might be an anti-pattern - for a library to start bringing in services from other sources in ways that aren't under control of the developer. For example, some of our unit tests provide a mock accessor because the real one isn't available or valid. |
I don't think that's an anti pattern. If we start using the options system we have to include that system in our di to get it even working. And adding something is not a problem. Last registration wins and is the default for di. So there are no problems as long as a user registers it's own implementation afterwards. And that is currently common in the ecosystem. |
My only other thought is that it could get registered twice, which wouldn't cause a functional difference. I suppose that's not a blocker. |
It's not added twice. Most of all framework dependencies are added with |
Is your feature request related to a problem? Please describe.
I'm in the process of setting up a proof of concept solution where I need a minimum asp.net core application just to have an actual endpoint over the wire. But adding Csla to the services is not "just" calling
AddCsla(o => o.AddAspNetCore())
but to also callAddHttpContextAccessor()
.Describe the solution you'd like
AddAspNetCore()
should internally callAddHttpContextAccessor()
because it's required in that scenario anyways.This would reduce the barrier on setting up a server. I had to check the samples to see how to correctly setup a server.
The text was updated successfully, but these errors were encountered: