Joh*_*ven 31 asp.net encryption web-config aspnet-regiis.exe system.configuration
我有一个带有自定义配置部分的Web应用程序.该部分包含我想要加密的信息(希望使用ASPNet_RegIIS而不是自己做).
Web.Config中:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="MyCustomSection"
type="MyNamespace.MyCustomSectionHandler, MyAssembly"/>
</configSections>
<configProtectedData>
<providers>
<clear />
<add name="DataProtectionConfigurationProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeyContainer"
useMachineContainer="true" />
</providers>
</configProtectedData>
<MyCustomSection>
<blah name="blah1">
<blahChild name="blah1Child1" />
</blah>
</MyCustomSection>
Run Code Online (Sandbox Code Playgroud)
配置处理程序在尝试加密之前工作得很好.当我尝试使用以下方法加密时:
aspnet_regiis -pef"MyCustomSection"c:\ inetpub\wwwroot\MyWebsite -prov DataProtectionConfigurationProvider
我收到一个错误:
加密配置部分...为MyCustomSection创建配置节处理程序时出错:无法加载文件或程序集"MyAssembly"或其依赖项之一.该系统找不到指定的文件.(c:\ inetpub\wwwroot\MyWebsite\web.config第5行)
我已尝试使用/不配置提供程序.有/无部分组.有/没有事先启动网站.我已经尝试暂时将我的程序集放入GAC进行注册.我也试过我的log4net部分只是尝试一些不是我的东西,没有运气.我以管理员身份运行命令提示符.有任何想法吗?或者ASPNet_RegIIS是否可以不用于自定义部分?
查看MSDN之后的最后一个镜头是将我的处理程序更改为继承自ConfigurationSection而不是实现IConfigurationSectionHandler,因为它在2.0中被技术上弃用(希望它是关于aspnet_regiis版本的东西).也没有运气.
任何想法让我知道.谢谢!
hwi*_*ers 33
aspnet_regiis
必须能够绑定程序集.正常的.net绑定规则适用.
我通过创建aspnet_regiis_bin
在同一目录中调用的目录 aspnet_regiis.exe
和作为私有路径的aspnet_regiis.exe.config
文件来解决这个问题,aspnet_regiis_bin
如下所示:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="aspnet_regiis_bin"/>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
然后我复制定义自定义配置节到组件aspnet_regiis_bin
,这样aspnet_regiis
可以找到它们.
此过程不要求程序集强名称或在GAC中,但需要在框架目录中进行处理.
Mat*_*nos 16
我正在使用一种解决方法,我暂时注释掉configSections元素的内容:
<configSection>
<!--
<section name="CustomSection" type="" />
-->
</configSection>
Run Code Online (Sandbox Code Playgroud)
然后,您可以aspnet_regiis -pef
照常运行加密.在运行之后,只需取消注释该部分,您的站点就可以运行了.
归档时间: |
|
查看次数: |
13482 次 |
最近记录: |