Bra*_*fur 12 asp.net configuration web-config
我使用文章创建灵活配置节处理程序在我的应用程序中创建灵活配置节处理程序.
我还在OdeToCode博客上看到了题为加密自定义配置部分的文章,介绍了如何加密web.config文件的各个部分.
从第一篇文章中,我们有了这个web.config代码.
<?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>
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码使用类似以下命令行代码的方式加密代码.
aspnet_regiis.exe -pef "StyleSheetSettings_1" C:\Test\
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
不能"从组件 '的System.Web,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a' 加载类型FifteenSeconds.Core.BasicConfigurator.
任何帮助,将不胜感激.
dni*_*els 19
以下是此问题的另一种解决方法(可在http://www.dotnetnoob.com/2013/01/how-to-encrypt-custom-configuration.html找到).在运行aspnet_regiis命令之前注释掉configSections元素(/ configuration/configSections)下自定义部分的section元素,并且自定义部分应该加密.
<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!
Run Code Online (Sandbox Code Playgroud)
尝试更改类型以包含程序集名称
type="FifteenSeconds.Core.BasicConfigurator, MyWebApplication"
Run Code Online (Sandbox Code Playgroud)
这假设 BasicConfiguration 位于您的 Web 应用程序中
| 归档时间: |
|
| 查看次数: |
5668 次 |
| 最近记录: |