0

我有一个链接到 common.config 文件的 web.config 文件。common.config 被多个应用程序使用。我使用了 aspnet_regiis.exe,但这只会加密 web.config 文件。如何加密 common.config 文件?

web.config 文件:

<?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 文件:

<?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>
4

2 回答 2

0

我找到了解决此问题的解决方法。希望能帮助到你。

  1. 暂时将您的 common.config 重命名为 web.config。

  2. 将配置作为根元素添加到此文件。所以你的 common.config 将如下所示。

<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. 运行加密命令。

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

  2. 打开加密文件并删除配置标签。

  3. 将文件重命名为 Common.config

于 2015-01-20T18:05:56.510 回答
0

我没有代表对原始帖子发表评论,但这看起来像是如何加密 .config 文件 Asp.net的副本

于 2015-01-20T16:41:25.793 回答