options pattern not working
migrated not so long ago .net 8 did they change something with the options pattern? it seems to not work anymore for some reason that i cant explain myself
see code below:
inside here it should retrive the stuff from the appsettings.json
but whenever i hit my AddInfrastructure point i get an error that it would be null see her:
options classes have similar schema each:
someone knows how to fix this?
12 Replies
you might be missing the configuration setup for the sections in your appsettings.json
what you mean by that?
I mean, ensure that the structure of your appsettings.json file matches the section names used in your options classes (JwtOptions and DatabaseConnectionOptions).
it does match already as you see?
or am i missing something
Make sure you are loading the configuration properly using the appropriate code at the beginning of your application.
its what iam doing above it
.net8 web api
Your configuration binding for JwtOptions and DatabaseConnectionOptions appears correct in the provided .NET code snippet for a web API
I don't have time to help you.
Hopefully I gave you enough information or wait for someone else
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
how does the validation then take place? does it throw an exception or?
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
then we are in a "double" concern issue state cause i register everything using clean architecture and extension methods for each layer
but thanks
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View