Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • John Bergman 481 posts 1120 karma points
    May 12, 2021 @ 22:05
    John Bergman

    GlobalSettings in a SurfaceController?

    Can anyone point me to where/how I would get the IGlobalSetings object while executing in a SurfaceController?

  • AddWeb Solution Pvt. Ltd 109 posts 354 karma points
    May 21, 2021 @ 05:32
    AddWeb Solution Pvt. Ltd

    Hello John,

    The GlobalSettings Class contains general settings information for the entire Umbraco instance based on information from web.config appsettings check this

  • Nik 1567 posts 7015 karma points MVP 6x c-trib
    May 21, 2021 @ 06:56

    Hi John,

    In V8 you should be able to take advantage of DI to get access to that.

    I would try something like this:

    public classs MySurfaceController : SurfaceController
           private readonly IGlobalSettings globalSettings;
           public MySurfaceController(IGlobalSettings globalSettings)
                   this.globalSettings = globalSettings;
           public ActionResult MyAction()
                   //do something with globalSettings 

    This should allow you access to that object assuming it is registered with the DI container. If it's not, I'm sure there will be a similar object that might wrap the global settings that can be injected.



Please Sign in or register to post replies

Write your reply to: