Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All-

I have hosted my web application in IIS 7.0. I want to encrypt connectionStrings in web.config file, but I dont have VS setup installed there. Is there any other option to encrypt the connection string in IIS? Or will it work if I copy the encrypted connection string from another machine which has VS setup?.

Please help.
Thanks in advance
Posted

1 solution

Can you check the below if this helps.
Encrypt ConnectionString in Web.Config[^]
 
Share this answer
 
v2
Comments
srmohanr 15-May-15 6:13am    
Hi Pradip,
Thanks for your reply. I dont have VS command prompt in the server where I have hosted the application. Also I have copied the encrypted connection string from another machine. That does not work.

Thanks.
Pradip Kumar Sen 15-May-15 7:59am    
I can understand your situation. If you can use any third party tool for encryption, that is fine, otherwise create a small console application, place the below code:

Configuration objConfig = WebConfigurationManager.OpenWebConfiguration("~");
// Give your config file path .


ConfigurationSection section = objConfig.GetSection("connectionStrings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
objConfig.Save();

}
//Below code is for decryption.
// if (section.SectionInformation.IsProtected)
// {

// section.SectionInformation.UnprotectSection();
// objConfig.Save();


// }


Copy this .exe file into your hosted server and run.
Follow if other installation option require like .msi file etc.

This is just a try again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900