加密一个web.config的自定义栏目 [英] Encrypting custom sections of a web.config

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

问题描述

我以前的文章创建一个灵活的配置节处理在我的应用程序创建一个灵活的配置节处理程序。

I used the article Creating a Flexible Configuration Section Handler to create a Flexible Configuration Section Handler in my application.

我也看到了这个文章,题为<一个href=\"http://odeto$c$c.com/blogs/scott/archive/2006/01/08/encrypting-custom-configuration-sections.aspx\">Encrypting在OdeTo code博客的自定义配置节,就如何加密web.config文件的部分。

I also saw this article entitled Encrypting Custom Configuration Sections on the OdeToCode blog, on how to encrypt portions of a web.config file.

从第一篇文章中,我们有这样的web.config code。

From the first article, we have this web.config code.

<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionname="StyleSheetSettings_1"    
            type="FifteenSeconds.Core.BasicConfigurator"/>
    </configSections>
    <StyleSheetSettings_1>
        <StyleSheets>
            <Style SheetName="Page"Href="Styles/Page.css"Media="screen"/>
            <StyleSheetName="Custom"Href="Styles/Custom.css"Media="screen"/>
            <StyleSheetName="Print"Href="/Lib/Styles/Print.css"Media="print"/>
        </StyleSheets>      
    </StyleSheetSettings_1>
 </configuration>

我试着用下面的code。使用类似下面的命令行code加密code。

I tried to use the following code to encrypt the code using something like the following command line code.

 aspnet_regiis.exe -pef  "StyleSheetSettings_1" C:\Test\

我收到以下错误

未能加载类型
  FifteenSeconds.Core.BasicConfigurator
  从程序集System.Web程序,
  版本= 4.0.0.0,文化=中立,
  公钥= b03f5f7f11d50a3a'。

Could not load type FifteenSeconds.Core.BasicConfigurator' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

下面是这个问题(在<一发现另一个解决方法href=\"http://www.dotnetnoob.com/2013/01/how-to-encrypt-custom-configuration.html\">http://www.dotnetnoob.com/2013/01/how-to-encrypt-custom-configuration.html).运行aspnet_regiis命令之前注释掉的configSections元素(/配置/ configSections)下的自定义栏目的部分元素和自定义栏目应该得到加密。

Here's another workaround for this issue (found at http://www.dotnetnoob.com/2013/01/how-to-encrypt-custom-configuration.html). Comment out the section element for the custom section under the configSections element (/configuration/configSections) before running the aspnet_regiis command and the custom section should get encrypted.

<configSections>
    <!--<section name="myCustomSection" type="My.Product.CustomSection, My.Product.Assembly/>-->
</configSections>


c:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -pef myCustomSection C:\path\to\app
Microsoft (R) ASP.NET RegIIS version 4.0.30319.17929
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Encrypting configuration section...
Succeeded!

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

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