Hi, not sure if this specific page should cover this but it should at least be somewhere around this section. I find the examples to be unrealistic in that all URLs and similar are hard-coded in source, and I'm frustrated that I can't find any documentation that covers how to do this properly. For example, in the AddJwtBearer callback I might need to access another DI service to obtain client certificates for the back channel http handler, or obtain endpoint URLs from appsettings.json. But since no IServiceProvider is passed into the callback, I'm at a loss how to get this working. All your examples are taking the easy way out by hard-coding values and are unhelpful in the real world.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Another example: Let's say in AddJwtBearer (or any other AddSchema-based extension) I set BackchannelHttpHandler to a HTTP Handler with a ServerCertificateCustomValidationCallback. I want that callback to be able to log certificate validation errors to a logger service. The logger service is obtained via dependency injection. How would I gain access to the DI tree from within that callback, so my logging will work?
@blowdart please respond.
This should be covered in the configuration pages, not in feature specific pages, otherwise you'd have to do it everywhere on every feature that needs configuration.
It sounds like both scenarios being asked about here are really about how to get access to services through DI when setting up options. I agree it would be best to document this in one place that other docs can reference. Filed https://github.com/aspnet/Docs/issues/10553 to track.
Or Add a Link to the Specific Page that will allow developers to Configure this Cases
Closing since moved to #10553 to track.
Most helpful comment
It sounds like both scenarios being asked about here are really about how to get access to services through DI when setting up options. I agree it would be best to document this in one place that other docs can reference. Filed https://github.com/aspnet/Docs/issues/10553 to track.