为了简化我们的web.config,我想使用configSource属性将NWebsec配置分解成一个单独的文件:
web.config
<?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事件查看器中也没有任何相关内容。
我所尝试的NWebsec配置是否可能?
如何更详细地了解正在发生并导致HTTP 500响应的错误?
发布于 2018-11-19 09:52:15
我认为这是因为nwebsec元素被定义为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)的根元素之外,还允许它按需要工作:
<?xml version="1.0"?>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="true">
...https://stackoverflow.com/questions/53342371
复制相似问题