• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Improve this Doc

Class Config

The Config class provides access to the web.config file.

Inheritance
System.Object
Config
Namespace: DotNetNuke.Common.Utilities
Assembly: DotNetNuke.dll
Syntax
public class Config : object

Methods

| Improve this Doc View Source

AddAppSetting(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

BackupConfig()

Creates a backup of the web.config file.

Declaration
public static void BackupConfig()
| Improve this Doc View Source

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.

| Improve this Doc View Source

GetAuthCookieTimeout()

Gets the authentication cookie timeout value.

Declaration
public static int GetAuthCookieTimeout()
Returns
Type Description
System.Int32

The timeout value.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetConnectionString()

Gets the default connection String as specified in the provider.

Declaration
public static string GetConnectionString()
Returns
Type Description
System.String

The connection String.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetDataBaseOwner()

Gets the specified database owner.

Declaration
public static string GetDataBaseOwner()
Returns
Type Description
System.String

The database owner.

| Improve this Doc View Source

GetDecryptionkey()

Returns the decryptionKey from web.config machineKey.

Declaration
public static string GetDecryptionkey()
Returns
Type Description
System.String

decryption key.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetFcnMode()

Returns the fcnMode from web.config httpRuntime.

Declaration
public static string GetFcnMode()
Returns
Type Description
System.String

FCN mode.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetObjectQualifer()

Gets the specified object qualifier.

Declaration
public static string GetObjectQualifer()
Returns
Type Description
System.String

The object qualifier.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

GetUpgradeConnectionString()

Gets the specified upgrade connection string.

Declaration
public static string GetUpgradeConnectionString()
Returns
Type Description
System.String

The connection String.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Load()

Loads the web.config file into an XML document.

Declaration
public static XmlDocument Load()
Returns
Type Description
XmlDocument

The configuration XML document.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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).

| Improve this Doc View Source

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).

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

Extension Methods

JsonExtensionsWeb.ToJson(Object)
  • View Source
Back to top by the community, for the community... #DNNCMS