【问题标题】:How to encrypt a file linked to a web.config如何加密链接到 web.config 的文件
【发布时间】:2015-03-18 21:58:04
【问题描述】:

我有一个链接到 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>

【问题讨论】:

标签: asp.net encryption aspnet-regiis.exe


【解决方案1】:

我没有代表对原始帖子发表评论,但这看起来像是 How to encrypt .config file Asp.net 的副本

【讨论】:

  • 嗯,这没有答案。为什么你把它作为答案而不是评论?
  • 我很抱歉;我还是新来的,所以我不知道如果没有回答仅几天前创建的原始线程,则允许创建重复线程,尽管那里有答案和 cmets。如果您阅读了我的“答案”,我已经回答了您关于我为什么不发表评论的问题。至少需要 50 个代表才能对我还没有的原始帖子发表评论。
【解决方案2】:

我找到了解决此问题的解决方法。希望对您有所帮助。

  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

【讨论】:

    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 2015-10-17
    • 1970-01-01
    • 2011-06-21
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多