0
votes

i want to encrypt the connectionstring section of my web.config. i have tried to do this by following the below steps:

  1. Open Developer Command Prompt for VS2013
  2. aspnet_regiis -pef "connectionStrings" -app "/E:\New folder\WebApplication1\WebApplication1"

it is thorwing me error "a configuration file cannot be created for the requested configuration object. failed"

I did some google but i am not able to get why i am facing this. i have tried to change the permissions of website folder?

do i need to set the website in IIS? please help me to solve this issue.

thanks in advance.

1

1 Answers

5
votes
<configuration>
<configProtectedData defaultProvider="SampleProvider">
<providers>
  <add name="SampleProvider" 
    type="System.Configuration.RsaProtectedConfigurationProvider, 
          System.Configuration, Version=2.0.0.0, Culture=neutral, 
          PublicKeyToken=b03f5f7f11d50a3a,
         processorArchitecture=MSIL"
    keyContainerName="SampleKeys" 
    useMachineContainer="true" />
</providers>

add above section into web.config.

  1. Open Developer Command Prompt for VS2013
  2. change directory to C:\Windows\Microsoft.NET\Framework\v4.0.30319 using cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

    1. run the following command

aspnet_regiis -pef "connectionStrings" "E:\New folder\WebApplication2\WebApplication2"

It encrypt the connection string. :)