<configSections> 位置引起的错误

今天在配置一个项目的时候,花了挺长时间配置完成,然后一启动项目,懵了,启动报错:错误显示

Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 
Parser Error Message: Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.

Unrecognized configuration section loggingProvider

最后纠结了半天,查了很多错误原因,因为没有直接搜索configSections错误,而是直接查询的错误,导致很长时间没有查出真正的原因,最后拿了别的web.config进行对比发现<configSections>的位置是靠在最前面的。调整好了,再运行,成功了。后来在网上查询说,<configSections>节点前不允许有其它节点。所以当我把它放在中间的时候则报上面的错误。

原文地址:https://www.cnblogs.com/wolfocme110/p/4267644.html