Joined: Sun Oct 19, 2008 3:47 pm Posts: 281 Has thanked: 0 time Have thanks: 1 time
Hi,
Can anyone help to , I use ASP .Net in my project , I try to encrypt my connection string in Web.config through OOP, I use this codes to encrypt the "ConnectionStrings", but when I run the application , it does't work.
In Class:ImportsMicrosoft.VisualBasicImportsSystem.ConfigurationImportsSystem.Web.C\ onfigurationImports System.SecurityPublic ClassEncConStrClassPublicSubEncryptConnStr(ByValprotectionProvider AsString)''---open the web.config fileDimconfig AsConfiguration = WebConfigurationManager.OpenWebConfiguration("")''---indicate the section to protectDimsection AsConfigurationSection = config.Sections("connectionStrings")''---specify the protection providersection.SectionInformation.ProtectSection(protectionProvider)'---Apple the protection and updateconfig.Save()EndSubsection.SectionInformation.UnProtectSection() config.Save() End
In Form "Behind Code":ProtectedSubPage_Load(ByValsender AsObject, ByVale AsSystem.EventArgs) HandlesMe.LoadDimX AsNewEncConStrClass''X.EncryptConnStr("DataProtectionConfigurationProvider")X.En\ cryptConnStr(
N.B: When I test this codes in form directly , it works & encrypted the connectionstring plz help me soon,"RSAProtectedConfigurationProvider")End SubPublicSubDecryptConnStr()Dimconfig AsConfiguration = WebConfigurationManager.OpenWebConfiguration("")Dimsection AsConfigurationSection = config.Sections("connectionStrings")EndSubClass
Habtujahkap
Question subject: Re: Encrypt connection string
Posted: Mon May 25, 2009 11:26 pm
Joined: Tue May 19, 2009 10:33 pm Posts: 2 Has thanked: 0 time Have thanks: 0 time
AskBot wrote:
Hi,
Can anyone help to , I use ASP .Net in my project , I try to encrypt my connection string in Web.config through OOP, I use this codes to encrypt the "ConnectionStrings", but when I run the application , it does't work.
In Class:ImportsMicrosoft.VisualBasicImportsSystem.ConfigurationImportsSystem.Web.C\ onfigurationImports System.SecurityPublic ClassEncConStrClassPublicSubEncryptConnStr(ByValprotectionProvider AsString)''---open the web.config fileDimconfig AsConfiguration = WebConfigurationManager.OpenWebConfiguration("")''---indicate the section to protectDimsection AsConfigurationSection = config.Sections("connectionStrings")''---specify the protection providersection.SectionInformation.ProtectSection(protectionProvider)'---Apple the protection and updateconfig.Save()EndSubsection.SectionInformation.UnProtectSection() config.Save() End
In Form "Behind Code":ProtectedSubPage_Load(ByValsender AsObject, ByVale AsSystem.EventArgs) HandlesMe.LoadDimX AsNewEncConStrClass''X.EncryptConnStr("DataProtectionConfigurationProvider")X.En\ cryptConnStr(
N.B: When I test this codes in form directly , it works & encrypted the connectionstring plz help me soon,"RSAProtectedConfigurationProvider")End SubPublicSubDecryptConnStr()Dimconfig AsConfiguration = WebConfigurationManager.OpenWebConfiguration("")Dimsection AsConfigurationSection = config.Sections("connectionStrings")EndSubClass