@HuwReddick thanks for the reply. Looks like that's for v8. When I attempted to apply that code to my SurfaceController in v9 IGlobalSettings doesn't exist.
That is a clean and strongly typed way of accessing a certain section. If you're using IConfiguration you can access the sections by configuration["Umbraco:CMS:Global"] but then you are dealing with string values.
Appsettings.json in SurfaceController
How do I access appsettings.json values in my SurfaceController?
https://our.umbraco.com/forum/using-umbraco-and-getting-started/105993-globalsettings-in-a-surfacecontroller
@HuwReddick thanks for the reply. Looks like that's for v8. When I attempted to apply that code to my SurfaceController in v9 IGlobalSettings doesn't exist.
I tried injecting IConfiguration like this:
But I get this error:
Hi!
Just take an
IConfiguration
in your constructor, and don't pass it along to thebase
constructor:As Johan stated, don't pass it to the base constructor, however I believe the correct DI would be something like
GlobalSettings would be the section you want from appsettings.jsom
@HuwReddick thank you for this! I actually ended up using a combination of yours and @JohanRunsten solution. Thank you both for your help!!
For anyone looking this helped with implementing the globalsettings: https://our.umbraco.com/documentation/Reference/Configuration/
That is a clean and strongly typed way of accessing a certain section. If you're using
IConfiguration
you can access the sections byconfiguration["Umbraco:CMS:Global"]
but then you are dealing with string values.is working on a reply...