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();