john8098
asked on
hide or encrypt connection string in asp.net applicaiton
Hi expert, please help.
I have try using code as follow, it encrypt well in my laptop, but after i upload to shard hosting envelopment. encrypt fail shown as follow.
System.Configuration.Confi gurationEr rorsExcept ion: An error occurred loading a configuration file: Access to the path 'C:\Domains\domainname.com .my\httpdo cs\8kgs3u4 _.tmp' is denied. (C:\Domains\domainname.com .my\httpdo cs\web.con fig) ---> System.UnauthorizedAccessE xception: Access to the path 'C:\Domains\domainname.com .my\httpdo cs\8kgs3u4 _.tmp' is denied. at System.IO.__Error.WinIOErr or(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init( String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor (String path, FileMode mode, FileAccess access) at System.CodeDom.Compiler.Te mpFileColl ection.Ens ureTempNam eCreated() at System.CodeDom.Compiler.Te mpFileColl ection.Add Extension( String fileExtension, Boolean keepFile) at System.CodeDom.Compiler.Te mpFileColl ection.Add Extension( String fileExtension) at System.Configuration.Inter nal.WriteF ileContext ..ctor(Str ing filename, String templateFilename) at System.Configuration.Inter nal.Intern alConfigHo st.StaticO penStreamF orWrite(St ring streamName, String templateStreamName, Object& writeContext, Boolean assertPermissions) at System.Configuration.Inter nal.Intern alConfigHo st.System. Configurat ion.Intern al.IIntern alConfigHo st.OpenStr eamForWrit e(String streamName, String templateStreamName, Object& writeContext, Boolean assertPermissions) at System.Configuration.Inter nal.Intern alConfigHo st.System. Configurat ion.Intern al.IIntern alConfigHo st.OpenStr eamForWrit e(String streamName, String templateStreamName, Object& writeContext) at System.Configuration.Inter nal.Delega tingConfig Host.OpenS treamForWr ite(String streamName, String templateStreamName, Object& writeContext) at System.Configuration.Updat eConfigHos t.OpenStre amForWrite (String streamName, String templateStreamName, Object& writeContext) at System.Configuration.MgmtC onfigurati onRecord.S aveAs(Stri ng filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll) --- End of inner exception stack trace --- at System.Configuration.MgmtC onfigurati onRecord.S aveAs(Stri ng filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll) at System.Configuration.Confi guration.S aveAsImpl( String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll) at System.Configuration.Confi guration.S ave() at test.EncryptConfig(Boolean bEncrypt)
I think the problem is show when the config.save is execute.
if i miss something or i there a way to get what appSettings.SectionInforma tion.Prote ctSection( "DataProte ctionConfi gurationPr ovider") have encrypt to show on label, so i can copy and paste it myself.
if can not be done, if there any way i can place it on my app_code by inherit ConfigurationSection or something to hide it from hacker. experts pls help.
I have try using code as follow, it encrypt well in my laptop, but after i upload to shard hosting envelopment. encrypt fail shown as follow.
System.Configuration.Confi
I think the problem is show when the config.save is execute.
if i miss something or i there a way to get what appSettings.SectionInforma
if can not be done, if there any way i can place it on my app_code by inherit ConfigurationSection or something to hide it from hacker. experts pls help.
Try
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath)
Dim appSettings As ConfigurationSection = config.GetSection("connectionStrings")
If bEncrypt Then
appSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
'appSettings.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider")
config.Save()
End If
Seems permission is not provided to your folder. Pease grant permission to AspNet(IIS 5.x) user account or Networkservices(IIS 6) to your root folder.
ASKER
If there possible to grant the permission on shared hosting?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.