❔ IOptions pattern in WebAPI getting null value
I'm trying to use the IOptions pattern with Dep. Injection, however when i debug the code i get null values in the injected object.
I've tried to use the
.AddOptions()
method to the builder
ServiceCollection
but still i get null values![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1144662205917298921/image.png)
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1144662206189936690/image.png)
6 Replies
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1144662471060230204/image.png)
whats the appsettings config look like?
are members of
Bot
properties?No theyre fields - that's likely the issue. I don't think config/options binding work with fields?
oops i didn't see the image
it doesn't
maybe there's a specific setting to enable it, but it's unusual and not recommended
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.