0

I have a web.config file that links to a common.config file. common.config is being used by multiple applications. I used the aspnet_regiis.exe, but that only encrypts the web.config file. How can i encrypt the common.config file?

web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings file="C:\Users\naem\Documents\common.config" />
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
</configuration>

common.config file:

<?xml version="1.0" encoding="utf-8"?>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="myKey" value="This is the Value!!!!"/>
  </appSettings>
User765876
  • 135
  • 2
  • 11
  • Possible duplicate of [How to encrypt .config file Asp.net](https://stackoverflow.com/questions/27991421/how-to-encrypt-config-file-asp-net) – Josef Bláha Jul 31 '17 at 15:20

2 Answers2

0

I don't have the rep to comment on the original post, but this looks like a duplicate of How to encrypt .config file Asp.net

Community
  • 1
  • 1
David
  • 137
  • 1
  • 2
  • 10
  • Well, that doesnt have the answer. And why did you put that as an answer and not a comment? – User765876 Jan 20 '15 at 16:49
  • My apologies; I'm still new here so I wasn't aware that creating a duplicate thread was allowed if the original one created only days ago wasn't answered, although there were answers and comments there. And if you read my "answer" I had already answered your question as to why I didn't comment. At least 50 rep is required to comment on an original post, which I don't yet have. – David Jan 20 '15 at 16:56
0

I found workaround to solve this issue. Hope it helps.

  1. Rename your common.config to web.config temporarily.

  2. Add configuration as root element to this file. So your common.config will look like as follows.

<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="myKey" value="This is the Value!!!!"/>
  </appSettings>
</configuration>
  1. Run encrypt command.

    aspnet_regiis.exe -pef appSettings "C:\Users\naem\Documents"

  2. Open encrypted file and remove Configuration tags.

  3. Rename file to Common.config

Pankaj Kapare
  • 7,486
  • 5
  • 40
  • 56