【发布时间】:2020-12-20 07:05:48
【问题描述】:
是否可以从后面的代码编辑 web.config 文件的“system.webServer”部分中的“httpErrors”?
我在使用时得到空值:
ConfigurationSection test = (ConfigurationSection)config.GetSection("system.webServer/httpErrors");
我想更改errorMode 和existingResponse 的值。同时删除嵌套在“httpErrors”中的任何现有“删除”或“错误”声明。
从这里:
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/ErrorPages/NotFound.aspx" />
</httpErrors>
到这里:
<httpErrors errorMode="Detailed" existingResponse="Auto" />
【问题讨论】:
标签: c# web-config code-behind