public PropertyBag GetCustomSettings() { PropertyBag bag = new PropertyBag(); ConfigurationSection section = ManagementUnit.Configuration.GetSection("system.webServer/myCustomSection"); bag[CustomGlobals.booleanProperty] = section.GetAttributeValue("booleanProperty"); bag[CustomGlobals.stringProperty] = section.GetAttributeValue("stringProperty"); bag[CustomGlobals.integerProperty] = section.GetAttributeValue("integerProperty"); return(bag); }
private void ReadSettings() { Configuration config = mgr.GetApplicationHostConfiguration(); ConfigurationSection sect = config.GetSection("BlockLinksSection"); permitBookmarks = (Boolean)sect.GetAttributeValue("permitBookmarks"); }
public static T value <T>(this ConfigurationSection section, string attributeName) { var value = section.GetAttributeValue(attributeName); if (value is T) { return((T)value); } return(default(T)); }
// Classes that inherit IHttpModule // must implement the Init and Dispose methods. public void Init(HttpApplication app) { // TODO: // Add initialization code // Including notifications app.BeginRequest += new EventHandler(app_BeginRequest); ts = new TraceSource("BlockLinks"); // create the server management object ServerManager sm = new ServerManager(); // Open the applicationHost.config data Configuration conf = sm.GetApplicationHostConfiguration(); // Open the configuration section ConfigurationSection sect = conf.GetSection("BlockLinksSection"); // Read the attribute value permitBookmarks = sect.GetAttributeValue("permitBookmarks").ToString(); }
private void updateIisRedirect(Website website, Configuration configuration) { ConfigurationSection cs = configuration.GetSection("system.webServer/httpRedirect"); if (website.IisSite.Mode == WebsiteIisMode.Redirect) { cs.SetAttributeValue("enabled", true); cs.SetAttributeValue("destination", website.IisSite.RedirectUrl); // For now, make these static, but they may need to be dynamic in future. cs.SetAttributeValue("exactDestination", true); cs.SetAttributeValue("childOnly", false); cs.SetAttributeValue("httpResponseStatus", 301); } else { // Only disable if currently enabled. if ((bool)cs.GetAttributeValue("enabled")) { // Enable, which creates web.config file. cs.SetAttributeValue("enabled", false); } } }
public static object value(this ConfigurationSection section, string attributeName) { return(section.GetAttributeValue(attributeName)); }