web.config 可以有一个通用的 system.webserver 部分和其他带有位置标签的 system.webserver 部分吗?

Can web.config have a general system.webserver section and other system.webserver sections with location tags?

我想在我所有网站的全局 system.webserver 部分中放置 url 重写 - 但我想要特定网站的 requestFiltering 部分 - 我可以有一个 "main" system.webserver 部分,然后是位置部分中的其他一些?

是的,你可以有一个 "global" system.webServer 部分(组)和许多 "location specific" 配置部分,它们有自己的 system.webServer 部分(组)。您可以在 ApplicationHost.config 和每个 web.config 中使用它。不过,您的问题的一个问题是要求 web.config 中的一般 system.webServer 部分适用于所有站点。除非所有站点共享相同的物理路径,否则您将无法对所有站点使用单个 web.config。相反,您希望将此配置放在 ApplicationHost.config 中。一些简单的阅读:https://docs.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/getting-started-with-configuration-in-iis-7-and-above