Last post Sep 09, 2013 01:50 AM by Starain chen - MSFT
Sep 05, 2013 12:10 PM|KeeEdwins|LINK
Is is possible to encrypt the web config file after deployment and if possible how do i do dat
Sep 05, 2013 05:34 PM|anas|LINK
People usually don't encrypt the whole file, they encrypt only the sensitive sections thta contains the user/passwords. Examples on these sections are "connectionStrings" and "Imporsenate" sections.
Here is an example using the aspnet_regiis tool
Of course, the tool need to be run on the server which hosts your app, so you need to have remote admin access to the server.
Sep 05, 2013 09:12 PM|musakkhir|LINK
Here are the commands to encrypt web.config file without any programming...
aspnet_regiis -pef "Section" "Path exluding web.config"
aspnet_regiis -pdf "Section" "Path exluding web.config"
Sep 05, 2013 09:28 PM|jats_ptl|LINK
I believe there are two ways of doing this:
using aspnet_regiis using DPAPI or RSA, or doing
The programmatic way can be handy, particularly if you also like to encrypt app.config.
From my experiences of using this, if you write a custom configuration section, you have install the DLL containing the classes for that section into the GAC. For a project I was working I basically scripted the following approach:
Chances are if you are just encrypting connection strings then this won't be a problem. You also need to be bear in mind whether you want to encrypt on a machine wide basis or to a specific user account- both options can be useful depending on your scenario.
For simplicity I stuck to machine wide encryption. The links I have provided explain the merits of both approaches.
Source: Encrypting Web.Config
Hope this helps.
Sep 06, 2013 07:59 AM|webcodeexpert|LINK
Read the following articles. it will surely help you.
How to Encrypt connection string in web.config | How to Decrypt connection string in web.config
Encrypt and Decrypt connectionString in web.config file using code in asp.net
Sep 06, 2013 11:42 AM|KeeEdwins|LINK
hi trying to use the code behind method but this is the error i get
System.Security.Cryptography.CryptographicException: Object already exists.
How can i fix it.
This is the code below
protected void BtnEncrypt_Click(object sender, EventArgs e)
Configuration confg = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection configSect = confg.GetSection(section);
if (configSect != null)
protected void BtnDecrypt_Click(object sender, EventArgs e)
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection configSect = config.GetSection(section);
Sep 07, 2013 10:43 AM|Tear09|LINK
Which line of code that you get that error?
Sep 09, 2013 01:50 AM|Starain chen - MSFT|LINK
Thanks for your post!
Based on my test. we will get that error if we run it without administrator permissions. So I suggest that you can run your
VS as administrator.
I also tried to publish that project and it works fine.