0
我想读取web.config文件不同部分的值。读取web.config文件的值
例如,
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" requestValidationMode="4.5"
maxRequestLength="102400" />
<pages validateRequest="true"></pages>
</system.web>
在这一节的System.Web我想读的httpRuntime requestValidationMode 值。在页面中,我想读取validateRequest的值。
另外,我想读的自定义标头值
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
<remove name="X-Powered-By" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
VAR customHeaders =(AppSettingsSection)ConfigurationManager.GetSection( “customHeaders”)和 VAR customHeaders = ConfigurationManager.GetSection( “customHeaders”)作为NameValueCollection中 两者都返回空值。 – ABB
我编辑它,我意识到你需要该部分的XPath。 –
我在global.asax.cs中写这段代码。我想要读取web.config文件并验证它 – ABB