Class Config
The Config class provides access to the web.config file.
Inheritance
Namespace: DotNetNuke.Common.Utilities
Assembly: DotNetNuke.dll
Syntax
public class Config : object
Methods
| Improve this Doc View SourceAddAppSetting(XmlDocument, String, String, Boolean)
Adds a new AppSetting to Web.Config. The update parameter allows you to define if, when the key already exists, this need to be updated or not.
Declaration
public static XmlDocument AddAppSetting(XmlDocument xmlDoc, string key, string value, bool update)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlDoc | xml representation of the web.config file. |
System.String | key | key to be created. |
System.String | value | value to be created. |
System.Boolean | update | If setting already exists, it will be updated if this parameter true. |
Returns
Type | Description |
---|---|
XmlDocument | An XML document. |
AddAppSetting(XmlDocument, String, String)
Adds a new AppSetting to Web.Config. If the key already exists, it will be updated with the new value.
Declaration
public static XmlDocument AddAppSetting(XmlDocument xmlDoc, string key, string value)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlDoc | xml representation of the web.config file. |
System.String | key | key to be created. |
System.String | value | value to be created. |
Returns
Type | Description |
---|---|
XmlDocument | An XML document. |
AddCodeSubDirectory(IApplicationStatusInfo, String)
Adds a code subdirectory to the configuration.
Declaration
public static void AddCodeSubDirectory(IApplicationStatusInfo appStatus, string name)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | name | The name of the code subdirectory. |
AddCodeSubDirectory(String)
Adds a code subdirectory to the configuration.
Declaration
public static void AddCodeSubDirectory(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the code subdirectory. |
AddFCNMode(IApplicationStatusInfo, Config.FcnMode)
Adds the File Change Notification (FCN) mode to the web.config if it does not yet exist.
Declaration
public static string AddFCNMode(IApplicationStatusInfo appStatus, Config.FcnMode fcnMode)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Config.FcnMode | fcnMode | The file change notification (FNC) mode. |
Returns
Type | Description |
---|---|
System.String | Always an empty string. |
AddFCNMode(Config.FcnMode)
Adds the File Change Notification (FCN) mode to the web.config if it does not yet exist.
Declaration
public static string AddFCNMode(Config.FcnMode fcnMode)
Parameters
Type | Name | Description |
---|---|---|
Config.FcnMode | fcnMode | The file change notification (FNC) mode. |
Returns
Type | Description |
---|---|
System.String | Always an empty string. |
BackupConfig()
Creates a backup of the web.config file.
Declaration
public static void BackupConfig()
BackupConfig(IApplicationStatusInfo)
Creates a backup of the web.config file.
Declaration
public static void BackupConfig(IApplicationStatusInfo statusInfo)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | statusInfo | The application status info. |
GetAuthCookieTimeout()
Gets the authentication cookie timeout value.
Declaration
public static int GetAuthCookieTimeout()
Returns
Type | Description |
---|---|
System.Int32 | The timeout value. |
GetAuthCookieTimeout(IApplicationStatusInfo)
Gets the authentication cookie timeout value.
Declaration
public static int GetAuthCookieTimeout(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.Int32 | The timeout value. |
GetConnectionString()
Gets the default connection String as specified in the provider.
Declaration
public static string GetConnectionString()
Returns
Type | Description |
---|---|
System.String | The connection String. |
GetConnectionString(String)
Gets the specified connection String.
Declaration
public static string GetConnectionString(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of Connection String to return. |
Returns
Type | Description |
---|---|
System.String | The connection String. |
GetCustomErrorMode()
Gets the currently configured custom error mode.
Declaration
public static string GetCustomErrorMode()
Returns
Type | Description |
---|---|
System.String | The currently configured custom error mode string. |
GetCustomErrorMode(IApplicationStatusInfo)
Gets the currently configured custom error mode.
Declaration
public static string GetCustomErrorMode(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.String | The currently configured custom error mode string. |
GetDataBaseOwner()
Gets the specified database owner.
Declaration
public static string GetDataBaseOwner()
Returns
Type | Description |
---|---|
System.String | The database owner. |
GetDecryptionkey()
Returns the decryptionKey from web.config machineKey.
Declaration
public static string GetDecryptionkey()
Returns
Type | Description |
---|---|
System.String | decryption key. |
GetDefaultProvider(String)
Gets the Dnn default provider for a given type.
Declaration
public static Provider GetDefaultProvider(string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | The type for which to get the default provider for. |
Returns
Type | Description |
---|---|
Provider | The default provider, Provider. |
GetFcnMode()
Returns the fcnMode from web.config httpRuntime.
Declaration
public static string GetFcnMode()
Returns
Type | Description |
---|---|
System.String | FCN mode. |
GetFriendlyUrlProvider()
Gets the currently configured friendly url provider.
Declaration
public static string GetFriendlyUrlProvider()
Returns
Type | Description |
---|---|
System.String | The name of the friendly url provider. |
GetMaxUploadSize()
Returns the maximum file size allowed to be uploaded to the application in bytes.
Declaration
public static long GetMaxUploadSize()
Returns
Type | Description |
---|---|
System.Int64 | Size in bytes. |
GetMaxUploadSize(IApplicationStatusInfo)
Returns the maximum file size allowed to be uploaded to the application in bytes.
Declaration
public static long GetMaxUploadSize(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.Int64 | Size in bytes. |
GetObjectQualifer()
Gets the specified object qualifier.
Declaration
public static string GetObjectQualifer()
Returns
Type | Description |
---|---|
System.String | The object qualifier. |
GetPathToFile(IApplicationStatusInfo, Config.ConfigFileType, Boolean)
Gets the path for the specified Config file.
Declaration
public static string GetPathToFile(IApplicationStatusInfo appStatus, Config.ConfigFileType file, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Config.ConfigFileType | file | The config.file to get the path for. |
System.Boolean | overwrite | force an overwrite of the config file. |
Returns
Type | Description |
---|---|
System.String | fully qualified path to the file. |
Remarks
Will copy the file from the template directory as required.
GetPathToFile(IApplicationStatusInfo, Config.ConfigFileType)
Gets the path for the specified Config file.
Declaration
public static string GetPathToFile(IApplicationStatusInfo appStatus, Config.ConfigFileType file)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Config.ConfigFileType | file | The config.file to get the path for. |
Returns
Type | Description |
---|---|
System.String | fully qualified path to the file. |
Remarks
Will copy the file from the template directory as required.
GetPathToFile(Config.ConfigFileType, Boolean)
Gets the path for the specified Config file.
Declaration
public static string GetPathToFile(Config.ConfigFileType file, bool overwrite)
Parameters
Type | Name | Description |
---|---|---|
Config.ConfigFileType | file | The config.file to get the path for. |
System.Boolean | overwrite | force an overwrite of the config file. |
Returns
Type | Description |
---|---|
System.String | fully qualified path to the file. |
Remarks
Will copy the file from the template directory as required.
GetPathToFile(Config.ConfigFileType)
Gets the path for the specified Config file.
Declaration
public static string GetPathToFile(Config.ConfigFileType file)
Parameters
Type | Name | Description |
---|---|---|
Config.ConfigFileType | file | The config.file to get the path for. |
Returns
Type | Description |
---|---|
System.String | fully qualified path to the file. |
Remarks
Will copy the file from the template directory as required.
GetPersistentCookieTimeout()
Gets optional persistent cookie timeout value from web.config.
Declaration
public static int GetPersistentCookieTimeout()
Returns
Type | Description |
---|---|
System.Int32 | The persistent cookie value. |
Remarks
Allows users to override default asp.net values.
GetPersistentCookieTimeout(IApplicationStatusInfo)
Gets optional persistent cookie timeout value from web.config.
Declaration
public static int GetPersistentCookieTimeout(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.Int32 | The persistent cookie value. |
Remarks
Allows users to override default asp.net values.
GetProvider(String, String)
Gets a provider by its type and name.
Declaration
public static Provider GetProvider(string type, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | The provider type. |
System.String | name | The provider name. |
Returns
Type | Description |
---|---|
Provider | The found provider, Provider. |
GetProviderPath(String)
Gets the specified provider path.
Declaration
public static string GetProviderPath(string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | type |
Returns
Type | Description |
---|---|
System.String | The provider path. |
GetRequestFilterSize()
Returns the maximum file size allowed to be uploaded based on the request filter limit.
Declaration
public static long GetRequestFilterSize()
Returns
Type | Description |
---|---|
System.Int64 | Size in megabytes. |
GetRequestFilterSize(IApplicationStatusInfo)
Returns the maximum file size allowed to be uploaded based on the request filter limit.
Declaration
public static long GetRequestFilterSize(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.Int64 | Size in megabytes. |
GetSection(String)
Gets a configuration section.
Declaration
public static object GetSection(string section)
Parameters
Type | Name | Description |
---|---|---|
System.String | section | The name of the section. |
Returns
Type | Description |
---|---|
System.Object | An object representing the application section. |
GetSetting(String)
Gets an application setting.
Declaration
public static string GetSetting(string setting)
Parameters
Type | Name | Description |
---|---|---|
System.String | setting | The name of the setting. |
Returns
Type | Description |
---|---|
System.String | A string representing the application setting. |
GetUpgradeConnectionString()
Gets the specified upgrade connection string.
Declaration
public static string GetUpgradeConnectionString()
Returns
Type | Description |
---|---|
System.String | The connection String. |
IsNet45OrNewer()
Checks if .Net Framework 4.5 or above is in use.
Declaration
public static bool IsNet45OrNewer()
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether .Net Framework 4.5 or above is in use. |
Load()
Loads the web.config file into an XML document.
Declaration
public static XmlDocument Load()
Returns
Type | Description |
---|---|
XmlDocument | The configuration XML document. |
Load(IApplicationStatusInfo, String)
Loads a configuration file as an XML document.
Declaration
public static XmlDocument Load(IApplicationStatusInfo appStatus, string filename)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | filename | The configuration file name. |
Returns
Type | Description |
---|---|
XmlDocument | The configuration as an XML document. |
Load(IApplicationStatusInfo)
Loads the web.config file into an XML document.
Declaration
public static XmlDocument Load(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
XmlDocument | The configuration XML document. |
Load(String)
Loads a configuration file as an XML document.
Declaration
public static XmlDocument Load(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The configuration file name. |
Returns
Type | Description |
---|---|
XmlDocument | The configuration as an XML document. |
RemoveCodeSubDirectory(IApplicationStatusInfo, String)
Removes a code subdirectory for the web.config file.
Declaration
public static void RemoveCodeSubDirectory(IApplicationStatusInfo appStatus, string name)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | name | The name of the code subdirectory. |
RemoveCodeSubDirectory(String)
Removes a code subdirectory for the web.config file.
Declaration
public static void RemoveCodeSubDirectory(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the code subdirectory. |
Save(IApplicationStatusInfo, XmlDocument, String)
Save an XML document to the application root folder.
Declaration
public static string Save(IApplicationStatusInfo appStatus, XmlDocument xmlDoc, string filename)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
XmlDocument | xmlDoc | The configuration as an XML document. |
System.String | filename | The file name to save to. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or the error message upon failure. |
Save(IApplicationStatusInfo, XmlDocument)
Save the web.config file.
Declaration
public static string Save(IApplicationStatusInfo appStatus, XmlDocument xmlDoc)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
XmlDocument | xmlDoc | The configuration as an XML document. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or the error message upon failure. |
Save(XmlDocument, String)
Save an XML document to the application root folder.
Declaration
public static string Save(XmlDocument xmlDoc, string filename)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlDoc | The configuration as an XML document. |
System.String | filename | The file name to save to. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or the error message upon failure. |
Save(XmlDocument)
Save the web.config file.
Declaration
public static string Save(XmlDocument xmlDoc)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlDoc | The configuration as an XML document. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or the error message upon failure. |
SetMaxUploadSize(IApplicationStatusInfo, Int64)
Sets the maximum file size allowed to be uploaded to the application in bytes.
Declaration
public static void SetMaxUploadSize(IApplicationStatusInfo appStatus, long newSize)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.Int64 | newSize | The new max upload size in bytes. |
SetMaxUploadSize(Int64)
Sets the maximum file size allowed to be uploaded to the application in bytes.
Declaration
public static void SetMaxUploadSize(long newSize)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | newSize | The new max upload size in bytes. |
Touch()
Touches the web.config file to force the application to reload.
Declaration
public static bool Touch()
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the operation succeeded. |
Touch(IApplicationStatusInfo)
Touches the web.config file to force the application to reload.
Declaration
public static bool Touch(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the operation succeeded. |
UpdateConnectionString(IApplicationStatusInfo, String)
Updates the database connection string.
Declaration
public static void UpdateConnectionString(IApplicationStatusInfo appStatus, string conn)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | conn | The connection string value. |
UpdateConnectionString(String)
Updates the database connection string.
Declaration
public static void UpdateConnectionString(string conn)
Parameters
Type | Name | Description |
---|---|---|
System.String | conn | The connection string value. |
UpdateDataProvider(IApplicationStatusInfo, String, String, String)
Updates the data provider configuration.
Declaration
public static void UpdateDataProvider(IApplicationStatusInfo appStatus, string name, string databaseOwner, string objectQualifier)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | name | The data provider name. |
System.String | databaseOwner | The database owner, usually dbo. |
System.String | objectQualifier | The object qualifier if multiple Dnn instance run under the same database (not recommended). |
UpdateDataProvider(String, String, String)
Updates the data provider configuration.
Declaration
public static void UpdateDataProvider(string name, string databaseOwner, string objectQualifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The data provider name. |
System.String | databaseOwner | The database owner, usually dbo. |
System.String | objectQualifier | The object qualifier if multiple Dnn instance run under the same database (not recommended). |
UpdateInstallVersion(IApplicationStatusInfo, Version)
UpdateInstallVersion, but only if the setting does not already exist.
Declaration
public static string UpdateInstallVersion(IApplicationStatusInfo appStatus, Version version)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Version | version | The version to update to. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateInstallVersion(Version)
UpdateInstallVersion, but only if the setting does not already exist.
Declaration
public static string UpdateInstallVersion(Version version)
Parameters
Type | Name | Description |
---|---|---|
Version | version | The version to update to. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateMachineKey()
Updates the unique machine key. Warning: Do not change this after installation unless you know what your are doing.
Declaration
public static string UpdateMachineKey()
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateMachineKey(IApplicationStatusInfo)
Updates the unique machine key. Warning: Do not change this after installation unless you know what your are doing.
Declaration
public static string UpdateMachineKey(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateMachineKey(XmlDocument)
Updates the unique machine key. Warning: Do not change this after installation unless you know what your are doing.
Declaration
public static XmlDocument UpdateMachineKey(XmlDocument xmlConfig)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlConfig | The configuration XML document. |
Returns
Type | Description |
---|---|
XmlDocument | The newly modified XML document. |
UpdateUpgradeConnectionString(IApplicationStatusInfo, String, String)
Updates the specified upgrade connection string.
Declaration
public static void UpdateUpgradeConnectionString(IApplicationStatusInfo appStatus, string name, string upgradeConnectionString)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
System.String | name | The connection string name. |
System.String | upgradeConnectionString | The new value for the connection string. |
UpdateUpgradeConnectionString(String, String)
Updates the specified upgrade connection string.
Declaration
public static void UpdateUpgradeConnectionString(string name, string upgradeConnectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The connection string name. |
System.String | upgradeConnectionString | The new value for the connection string. |
UpdateValidationKey()
Updates the validation key. WARNING: Do not call this API unless you now what you are doing.
Declaration
public static string UpdateValidationKey()
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateValidationKey(IApplicationStatusInfo)
Updates the validation key. WARNING: Do not call this API unless you now what you are doing.
Declaration
public static string UpdateValidationKey(IApplicationStatusInfo appStatus)
Parameters
Type | Name | Description |
---|---|---|
IApplicationStatusInfo | appStatus | The application status info. |
Returns
Type | Description |
---|---|
System.String | An empty string upon success or an error message upon failure. |
UpdateValidationKey(XmlDocument)
Updates the validation key. WARNING: Do not call this APi unless you now what you are doing.
Declaration
public static XmlDocument UpdateValidationKey(XmlDocument xmlConfig)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlConfig | The XML configuration document. |
Returns
Type | Description |
---|---|
XmlDocument | The newly modified XML configuration document. |