I use Application Request Routing with URL Rewrite where I want setup Server Variable (HTTP_SEC_WEBSOCKET_EXTENSION) in installer. There are two config for configuration
web.config
which I can configure correctly usingServerManager
classapplicationHost.config
where I have problem
I tried using principles described in MS IIS Help.
Example of my code with dexription:
Configuration applicationHostConfig = serverManager.GetApplicationHostConfiguration();
// Section Path is not working. I get the string from applicationHost.config after manually
// adding the server variable. Look at the error listing below.
ConfigurationSection section = applicationHostConfig.GetSection("system.webServer/rewrite/allowedServerVariables/add", "MyWeb");
ConfigurationAttribute enabled = section.GetAttribute("name");
enabled.Value = "HTTP_SEC_WEBSOCKET_EXTENSION";
// Part from MS example which working fine.
ConfigurationSection section = applicationHostConfig.GetSection("system.webServer/defaultDocument", "TeCo");
ConfigurationAttribute enabled = section.GetAttribute("enabled");
enabled.Value = false;
serverManager.CommitChanges();
Error:
System.Runtime.InteropServices.COMException (0x80070490): Filename: \?C:WWWMyWebweb.config
Error: The configuration section 'system.webServer/rewrite/allowedServerVariables/add'
cannot be read because it is missing a section declaration
I don’t know why it tries to read from web.config
when I use GetApplicationHostConfiguration()