Enterprise appSettings Sections

Vote:
 
Hi I have an enterprise EPiServer installation with 2 sites. You can see in the web.config file that each site "instance" has its own appSettings section in the section. EPiServer obviously reads some of the sites settings from here but when i add my own settings to this section asp.net just uses the default entry from the section. How can i get the instance specific appSettings in my asp.net page? Thanks Ben Crinion
#12745
Aug 21, 2006 10:47
Vote:
 
I have found the answer. Just use Global.EPConfig["keyname"] and it gets the instance specific setting. Thanks Ben
#14821
Aug 21, 2006 11:57
Vote:
 
Good catch! Another reason for using the EPiServer conig reader is to make sure any encrypted values are decrypted before you use them. The built-in .NET FW ConfigurationSettings.AppSettings will not do that for you. Another little known fact is the prefix functionality. From the sdk: Enter the following lines in web.config (inside the appSettings section): Enter the following lines in an .aspx file: <%# EPiServer.Global.EPConfig["EPfShowNewsOnFrontPage"].GetType().ToString() %> <%# EPiServer.Global.EPConfig["ShowNewsOnFrontPage"].GetType().ToString() %> You'll get the result: System.Boolean System.String So, EPn (n for number), EPs (s for string) and EPf (f for flag) will be converted to the correct type for you automatically, you do not have to parse it yourself, you only have to cast it. // This will never throw an nullreference or cast exception, // even if the setting does not exists bool showSomething = (bool)Global.EPConfig["EPfShowSomething"]; If a setting has not been defined in the web.config file, or there is a problem parsing the values, the default value will be used instead: EPf: false EPn: 0 EPs: string.Empty So, the prefixes for all those EPiServer keys in web.config are there for a specific reason, not just for aesthetics. :-) /Steve
#14822
Aug 21, 2006 17:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.