如何加密链接到一个web.config一个文件 [英] How to encrypt a file linked to a web.config

查看:164
本文介绍了如何加密链接到一个web.config一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个链接到common.config文件web.config文件。 common.config正在使用的多个应用程序。我用了ASPNET_REGIIS.EXE,但只有加密的web.config文件。我怎样才能加密common.config文件?

web.config文件:

 <?XML版本=1.0编码=UTF-8&GT?;
<结构>
  <文件的appSettings =C:\\用户\\ NAEM \\文档\\ common.config/>
  <&的System.Web GT;
    <编译调试=真targetFramework =4.5/>
    <的httpRuntime targetFramework =4.5/>
  < /system.web>
< /结构>

common.config文件:

 <?XML版本=1.0编码=UTF-8&GT?;
  <&的appSettings GT;
    <添加键=网页:版本值=3.0.0.0/>
    <添加键=网页:启用VALUE =FALSE/>
    <添加键=ClientValidationEnabledVALUE =真/>
    <添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
    <添加键=的myKeyVALUE =这就是价值!!!!/>
  < /的appSettings>


解决方案

我找到的解决方法来解决这个问题。希望它帮助。


  1. 重命名common.config到web.config中暂时的。


  2. 添加配置,根元素到此文件。所以,你的common.config看起来就像如下:


 <结构>
  <&的appSettings GT;
    <添加键=网页:版本值=3.0.0.0/>
    <添加键=网页:启用VALUE =FALSE/>
    <添加键=ClientValidationEnabledVALUE =真/>
    <添加键=UnobtrusiveJavaScriptEnabledVALUE =真/>
    <添加键=的myKeyVALUE =这就是价值!!!!/>
  < /的appSettings>
< /结构>

<醇开始=3>

  • 运行加密命令。

    ASPNET_REGIIS.EXE -pef的appSettingsC:\\用户\\ NAEM \\文件


  • 打开加密的文件,并删除配置标签。


  • 重命名文件Common.config


  • 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>
    

    解决方案

    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

    这篇关于如何加密链接到一个web.config一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆