Пример #1
0
        //*********************************************************************
        //
        // SaveSiteSettings Method <a name="SaveSiteSettings"></a>
        //
        // The Configuration.SaveSiteSettings overwrites the the XML file with the
        // settings in the SiteConfiguration object in context.  The object will in
        // turn be evicted from the cache and be reloaded from the XML file the next
        // time GetSiteSettings() is called.
        //
        //*********************************************************************
        public void SaveSiteSettings()
        {
            // Obtain SiteSettings from the Cache
            SiteConfiguration siteSettings = (SiteConfiguration)HttpContext.Current.Cache["SiteSettings"];

            // Check the object
            if (siteSettings == null)
            {
                // If SaveSiteSettings() is called once, the cache is cleared.  If it is
                // then called again before Global.Application_BeginRequest is called,
                // which reloads the cache, the siteSettings object will be Null
                siteSettings = GetSiteSettings();
            }
            string configFile = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["configFile"]);

            // Object is evicted from the Cache here.
            siteSettings.WriteXml(configFile);
        }