asp.net config 配置

1

<httpErrors errorMode="Custom" existingResponse="Replace">
<clear/>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" path="/testapp/nofound.ashx" responseMode="ExecuteURL"/>
</httpErrors>

error[path]必须是绝对路径,如果有虚拟目录,还得指定虚拟目录

2.在很多时候我们需要自定义我们自己的自定义App.config 文件,而微软为我们提供了默认的

      System.Configuration.NameValueSectionHandler  NameValueCollection
      System.Configuration.DictionarySectionHandler  Hashtable
      System.Configuration.SingleTagSectionHandler  Hashtable

<section name="SingleTagSectionTest" type="System.Configuration.SingleTagSectionHandler" />
<section name="DictionarySectionTest" type="System.Configuration.DictionarySectionHandler" />
<section name="NameValueSectionTest" type="System.Configuration.NameValueSectionHandler" />

<SingleTagSectionTest user="test" age="30" birthday="2020-01-01"/>
<DictionarySectionTest>
<add key="user" value="a" />
<add key="user" value="b" />
<add key="age" value="30" />
</DictionarySectionTest>
<NameValueSectionTest>
<add key="user" value="a" />
<add key="user" value="b" />
<add key="age" value="30" />
</NameValueSectionTest>


https://docs.microsoft.com/zh-cn/dotnet/api/system.configuration.iconfigurationsectionhandler?view=netcore-3.0

原文地址:https://www.cnblogs.com/lizhanglong/p/6941622.html