簡體   English   中英

如何加密鏈接到web.config的文件

[英]How to encrypt a file linked to a web.config

我有一個鏈接到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>

我沒有代表對原始帖子發表評論,但這看起來像如何加密.config文件Asp.net的副本

我找到了解決此問題的方法。 希望能幫助到你。

  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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM