locked
colon : in appsettings RRS feed

  • Question

  • User-1416423428 posted

    I was browsing the source code of MiniBlog with the goal of studying some of its techniques. 

    Theme = ConfigurationManager.AppSettings.Get("blog:theme");
    

    I noticed they're using a colon (:) in the appsettings.get.  Is there any special significance to this? Or is this just like any letter/character you can use? 

    Saturday, April 19, 2014 1:45 PM

Answers

  • User-760709272 posted

    No, it's just a way of grouping settings, so any settings regarding "blog" will start with "blog:"  Other common conventions are using a ".", so "blog.theme" etc.  Such naming conventions also allow you to build your own config classes, like;

    BlogSettings.Get("theme")

    and all "Get" in "BlogSettings" does is add "blog:" to the start of the requested setting, so you could also have

    ProductSettings.Get("theme")

    and under the covers that will access the "product:theme" setting.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 19, 2014 3:36 PM

All replies

  • User-760709272 posted

    No, it's just a way of grouping settings, so any settings regarding "blog" will start with "blog:"  Other common conventions are using a ".", so "blog.theme" etc.  Such naming conventions also allow you to build your own config classes, like;

    BlogSettings.Get("theme")

    and all "Get" in "BlogSettings" does is add "blog:" to the start of the requested setting, so you could also have

    ProductSettings.Get("theme")

    and under the covers that will access the "product:theme" setting.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 19, 2014 3:36 PM
  • User-1416423428 posted
    So you can use dots and colons as valid characters for use in app setting names? They're not specially treated by asp.net in any way, it's just for user readability?
    Saturday, April 19, 2014 6:32 PM
  • User-760709272 posted

    Yeah it's just for readability.

    Sunday, April 20, 2014 7:46 AM