private RewriterRuleCollection rules; // an instance of the RewriterRuleCollection class... /// <summary> /// GetConfig() returns an instance of the <b>RewriterConfiguration</b> class with the values populated from /// the Web.config file. It uses XML deserialization to convert the XML structure in Web.config into /// a <b>RewriterConfiguration</b> instance. /// </summary> /// <returns>A <see cref="RewriterConfiguration"/> instance.</returns> public static RewriterConfiguration GetConfig() { string key = "RewriterConfig"; //if (HttpContext.Current.Cache[key] == null) // HttpContext.Current.Cache.Insert("RewriterConfig", ConfigurationSettings.GetConfig("RewriterConfig")); if (HttpContext.Current.Cache[key] == null) { object obj = System.Configuration.ConfigurationManager.GetSection("RewriterConfig"); if (obj != null) HttpContext.Current.Cache.Insert(key, obj); else { System.Xml.XmlDocument config = new System.Xml.XmlDocument(); string path = "";// string.Format("{0}\\app_data\\rewrite.xml", HttpContext.Current.Server.MapPath("~/")); //path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["RewriteConfig"]); path = AppDomain.CurrentDomain.BaseDirectory + "app_data\\nrewrite.config"; if (!System.IO.File.Exists(path)) path = AppDomain.CurrentDomain.BaseDirectory + "app_data\\nrewrite.xml"; config.Load(path); object configObj = new RewriterConfigSerializerSectionHandler().Create(null, null, config.SelectSingleNode("RewriterConfig")); HttpRuntime.Cache.Insert(key, configObj, new System.Web.Caching.CacheDependency(path)); } } return (RewriterConfiguration)HttpContext.Current.Cache[key]; }
private RewriterRuleCollection rules; // an instance of the RewriterRuleCollection class... /// <summary> /// GetConfig() returns an instance of the <b>RewriterConfiguration</b> class with the values populated from /// the Web.config file. It uses XML deserialization to convert the XML structure in Web.config into /// a <b>RewriterConfiguration</b> instance. /// </summary> /// <returns>A <see cref="RewriterConfiguration"/> instance.</returns> public static RewriterConfiguration GetConfig() { string key = "RewriterConfig"; //if (HttpContext.Current.Cache[key] == null) // HttpContext.Current.Cache.Insert("RewriterConfig", ConfigurationSettings.GetConfig("RewriterConfig")); if (HttpContext.Current.Cache[key] == null) { object obj = System.Configuration.ConfigurationManager.GetSection("RewriterConfig"); if (obj != null) { HttpContext.Current.Cache.Insert(key, obj); } else { System.Xml.XmlDocument config = new System.Xml.XmlDocument(); string path = "";// string.Format("{0}\\app_data\\rewrite.xml", HttpContext.Current.Server.MapPath("~/")); //path = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["RewriteConfig"]); path = AppDomain.CurrentDomain.BaseDirectory + "app_data\\nrewrite.config"; if (!System.IO.File.Exists(path)) { path = AppDomain.CurrentDomain.BaseDirectory + "app_data\\nrewrite.xml"; } config.Load(path); object configObj = new RewriterConfigSerializerSectionHandler().Create(null, null, config.SelectSingleNode("RewriterConfig")); HttpRuntime.Cache.Insert(key, configObj, new System.Web.Caching.CacheDependency(path)); } } return((RewriterConfiguration)HttpContext.Current.Cache[key]); }