2
我希望能够以编程方式确定System.webServer/Security/requestFiltering部分是否存在于我的应用程序的web.config文件中。 我能够使用下面的代码为system.web等其他部分做到这一点,但到目前为止没有与system.WebServer的运气。如何检查System.webServer/Security/requestFiltering部分是否以编程方式存在?
var config = WebConfigurationManager.OpenWebConfiguration("~");
HttpRuntimeSection section = config.GetSection("system.web/httpRuntime") as HttpRuntimeSection;
Label1.Text = section.MaxRequestLength.ToString();