Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 28058

Why does the IIS ServerManager class create my handler mapping disabled?

$
0
0
I want to add a handler mapping (script map) for our custom CGI-Exe to an Internet Information Server using the classes in the Microsoft.Web.Administration namespace. The (simplified) code is: var serverManager = ServerManager.OpenRemote(serverName); Configuration webConfig = serverManager.GetWebConfiguration(siteName, appPath); ConfigurationSection handlersSection = webConfig.GetSection("system.webServer/handlers"); ConfigurationElementCollection handlersCollection = handlersSection.GetCollection(); string elementName = cgiFile + " script map appHost added by ACM"; ConfigurationElement addElement = handlersCollection.CreateElement("add"); addElement["allowPathInfo"] = true; addElement["modules"] = "CgiModule"; addElement["name"] = elementName; addElement["path"] = cgiFile; addElement["requireAccess"] = "Execute”; addElement["scriptProcessor"] = Path.Combine(scriptsPath, cgiFile); addElement["verb"] = "*"; handlersCollection.Add(addElement); serverManager.CommitChanges(); This code adds the handler mapping to the mapping list in the IIS, but it is marked as disabled. I have to manually select “Edit Feature Permissions…” from the Actions pane and select the “Execute” permission. I want to know how to enable the handler mapping, either by setting different configuration options while creating the handler or by programmatically editing the feature permissions. Uhh, how do you format code in this forum (or even add paragraphs)?

Viewing all articles
Browse latest Browse all 28058

Trending Articles