在NWebsec中使用configSource

时间:2018-11-16 17:04:21

标签: asp.net web-config nwebsec

为了简化我们的extractT :: Proxy T -> T extractT _ = T (Proxy :: Proxy ()) ,我想使用web.config属性将NWebsec配置分解为一个单独的文件:

configSource

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

当我向应用程序发出请求时,我现在收到一个HTTP 500错误,没有其他详细信息。 Windows事件查看器中也没有任何内容。

使用NWebsec配置可以做些什么吗?

如何更详细地了解正在发生并导致HTTP 500响应的错误?

1 个答案:

答案 0 :(得分:1)

我相信这是因为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">
  ...
相关问题