I am trying to implement custom configuration in my web apps.
In my web config I have added the following sections:
<configsections>
<section name="SecurityConfiguration" type="EncryptStringTesting.CustomConfiguration, EncryptStringTesting" />
</configsections>
<securityconfiguration>
<stringencryptdecryptpassword value="" />
</securityconfiguration>
I've add a new class CustomConfiguration with following code:
Inherits System.Configuration.ConfigurationSection
#Region " Properties "
<configurationproperty("value",> _
Public Property value() As String
Get
Return CStr(Me("value"))
End Get
Set(ByVal value As String)
Me("value") = value
End Set
End Property
<configurationproperty("stringencryptdecryptpassword",> DefaultValue:="", _
IsRequired:=True, IsKey:=True)> _
Public Property StringEncryptDecryptPassword() As String
Get
Return CStr(Me("StringEncryptDecryptPassword"))
End Get
Set(ByVal value As String)
Me("StringEncryptDecryptPassword") = value
End Set
End Property
In my web page I am try to retrive my custom values:
Dim config As New CustomConfiguration
config = System.Configuration.ConfigurationManager.GetSection("SecurityConfiguration")
Response.Write(config.StringEncryptDecryptPassword.ToString)
When I call System.Configuration.ConfigurationManager.GetSection("SecurityConfiguration") getting nothing. Could you tell me why?