我通过该ApplicationHost.CreateApplicationHost方法托管ASP.NET运行时.当我修改web.config应用程序运行时,我看到很多第一次机会ThreadAbortException抛出.这是在我的应用程序崩溃之前.我假设这是因为运行时已检测到配置更改并想要重新启动.
这对我们来说并不是真正受支持的场景,所以我更愿意,如果我可以关闭自动重新加载.
有谁知道如何做到这一点?
我有一个带有自定义配置部分的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版本的东西).也没有运气.
任何想法让我知道.谢谢!
asp.net encryption web-config aspnet-regiis.exe system.configuration