Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How do I access appsettings.json values in my 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:
: base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider, configuration)
But I get this error:
'SurfaceController' does not contain a constructor that takes 7 arguments
Just take an IConfiguration in your constructor, and don't pass it along to the base constructor:
...) : base(umbracoContextAccessor, databaseFactory, services, appCaches, profilingLogger, publishedUrlProvider)
this._configuration = configuration;
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
"From": "[email protected]",
@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:
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted