C
C#2y ago
Davide

❔ 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
6 Replies
Davide
DavideOP2y ago
phaseshift
phaseshift2y ago
whats the appsettings config look like?
this_is_pain
this_is_pain2y ago
are members of Bot properties?
phaseshift
phaseshift2y ago
No theyre fields - that's likely the issue. I don't think config/options binding work with fields?
this_is_pain
this_is_pain2y ago
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
Accord
Accord2y ago
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.

Did you find this page helpful?