在NWebsec中使用configSource [英] Using configSource with NWebsec
问题描述
为了简化我们的 web.config
,我想使用 configSource
属性将NWebsec配置分解为一个单独的文件:
In an attempt to simplify our web.config
, I wanted to break out the NWebsec configuration into a separate file using the configSource
attribute:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="nwebsec">
<section name="httpHeaderSecurityModule" type="NWebsec.Modules.Configuration.HttpHeaderSecurityConfigurationSection, NWebsec, Version=4.2.0.0, Culture=neutral, PublicKeyToken=3613da5f958908a1" requirePermission="false" />
</sectionGroup>
</configSections>
<nwebsec configSource="App_Config\NWebsec.config" />
<!--- remainder of file omitted for brevity -->
</configuration>
App_Config \ NWebsec.config
<?xml version="1.0"?>
<nwebsec>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="true">
<!-- omitted for brevity -->
</redirectValidation>
<securityHttpHeaders>
<!-- omitted for brevity -->
</securityHttpHeaders>
</httpHeaderSecurityModule>
</nwebsec>
当我向应用程序发出请求时,我现在收到一个HTTP 500错误,没有其他详细信息.Windows事件查看器中也没有任何内容.
When I make a request to the application I now receive a HTTP 500 error with no other details. There is also nothing related in the Windows Event Viewer.
使用NWebsec配置是否可以实现?
Is what I'm attempting possible with NWebsec configuration?
如何更详细地了解正在发生并导致HTTP 500响应的错误?
How do I get more detail on the error which is occurring and causing the HTTP 500 response?
推荐答案
我相信这是因为 nwebsec
元素被定义为 sectionGroup
:
I believe this is because the nwebsec
element is defined as a sectionGroup
:
<sectionGroup name="nwebsec">
<section name="httpHeaderSecurityModule" type="..." />
</sectionGroup>
configSource
属性仅适用于 section
元素.
修改 web.config
:
<nwebsec>
<httpHeaderSecurityModule configSource="App_Config\NWebsec.config" />
</nwebsec>
除了修改引用文件的根元素( App_Config \ NWebsec.config
)之外,还可以使其按需工作:
In addition to amending the root element of the referenced file (App_Config\NWebsec.config
), enables this to work as desired:
<?xml version="1.0"?>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="true">
...
这篇关于在NWebsec中使用configSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!