public static void Main()
        {
// <Snippet1>
            // Get the Web application configuration.
            System.Configuration.Configuration webConfig =
                WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

            // Get the section.

            string configPath =
                "system.web/caching/outputCacheSettings";

            System.Web.Configuration.OutputCacheSettingsSection outputCacheSettings =
                (System.Web.Configuration.OutputCacheSettingsSection)webConfig.GetSection(
                    configPath);


// </Snippet1>

// <Snippet2>

            // Create a OutputCacheSettingsSection object.
            System.Web.Configuration.OutputCacheSettingsSection outCacheSettings =
                new System.Web.Configuration.OutputCacheSettingsSection();

// </Snippet2>

// <Snippet3>
            // Get the current OutputCacheProfiles property value.
            OutputCacheProfileCollection outputCacheProfilesValue =
                outputCacheSettings.OutputCacheProfiles;

// </Snippet3>
        }
Exemple #2
0
        static CacheSettings()
        {
            outputCacheSettings = WebConfigurationManager.GetWebApplicationSection("system.web/caching/outputCacheSettings") as OutputCacheSettingsSection;

            if (outputCacheSettings != null)
            {
                cdnCacheSettings = outputCacheSettings.OutputCacheProfiles["Home_CDN"];
            }
        }
        public static void Main(string[] args)
        {
// <Snippet1>

            // Get the Web application configuration.
            System.Configuration.Configuration webConfig =
                WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

            // Get the section.
            string configPath =
                "system.web/caching/outputCacheSettings";

            System.Web.Configuration.OutputCacheSettingsSection outputCacheSettings =
                (System.Web.Configuration.OutputCacheSettingsSection)webConfig.GetSection(
                    configPath);

            // Get the profile collection.
            System.Web.Configuration.OutputCacheProfileCollection outputCacheProfiles =
                outputCacheSettings.OutputCacheProfiles;

// </Snippet1>


// <Snippet2>
            // Execute the Add method.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile0 =
                new System.Web.Configuration.OutputCacheProfile("MyCacheProfile");
            outputCacheProfile0.Location =
                System.Web.UI.OutputCacheLocation.Any;
            outputCacheProfile0.NoStore = false;

            outputCacheProfiles.Add(outputCacheProfile0);

            // Update if not locked.
            if (!outputCacheSettings.IsReadOnly())
            {
                webConfig.Save();
            }
// </Snippet2>


// <Snippet3>
            // Execute the Clear method.
            outputCacheProfiles.Clear();
// </Snippet3>

// <Snippet4>

            // Get the profile with the specified index.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile2 =
                outputCacheProfiles[0];

// </Snippet4>

// <Snippet5>
            // Get the profile with the specified name.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile3 =
                outputCacheProfiles["MyCacheProfile"];

// </Snippet5>


// <Snippet6>
            // Get the key with the specified index.
            string theKey = outputCacheProfiles.GetKey(0).ToString();

// </Snippet6>

// <Snippet7>
            // Remove the output profile with the specified index.
            outputCacheProfiles.RemoveAt(0);

// </Snippet7>


// <Snippet8>
            // Remove the output profile with the specified name.
            outputCacheProfiles.Remove("MyCacheProfile");

// </Snippet8>

// <Snippet9>
            // Get the keys.
            object [] keys = outputCacheProfiles.AllKeys;

// </Snippet9>

// <Snippet10>
            // Execute the Set method.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile =
                new System.Web.Configuration.OutputCacheProfile("MyCacheProfile");
            outputCacheProfile.Location =
                System.Web.UI.OutputCacheLocation.Any;
            outputCacheProfile.NoStore = false;

            outputCacheProfiles.Set(outputCacheProfile);

            // Update if not locked.
            if (!outputCacheSettings.IsReadOnly())
            {
                webConfig.Save();
            }
// </Snippet10>

            // <Snippet11>
            // Get the profile with the specified name.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile4 =
                outputCacheProfiles.Get("MyCacheProfile");

            // </Snippet11>

            // <Snippet12>
            // Get thge profile with the specified index.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile5 =
                outputCacheProfiles.Get(0);
            // </Snippet12>
        }
Exemple #4
0
        public static void Main()
        {
// <Snippet1>
            // Get the Web application configuration.
            System.Configuration.Configuration webConfig =
                WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

            // Get the section.

            string configPath =
                "system.web/caching/outputCacheSettings";

            System.Web.Configuration.OutputCacheSettingsSection outputCacheSettings =
                (System.Web.Configuration.OutputCacheSettingsSection)webConfig.GetSection(
                    configPath);

            // Get the profile at zero index.
            System.Web.Configuration.OutputCacheProfile outputCacheProfile =
                outputCacheSettings.OutputCacheProfiles[0];

// </Snippet1>

// <Snippet2>

            // Get the current VaryByHeader.
            String varyByHeaderValue =
                outputCacheProfile.VaryByHeader;

            // Set the VaryByHeader.
            outputCacheProfile.VaryByHeader =
                string.Empty;

// </Snippet2>

// <Snippet3>

            // Get the current VaryByControl.
            String varyByControlValue =
                outputCacheProfile.VaryByControl;

            // Set the VaryByControl.
            outputCacheProfile.VaryByControl =
                string.Empty;

// </Snippet3>

// <Snippet4>

            // Get the current NoStore.
            Boolean noStoreValue =
                outputCacheProfile.NoStore;

            // Set the NoStore.
            outputCacheProfile.NoStore = false;

// </Snippet4>

// <Snippet5>

            // Get the current Location.
            System.Web.UI.OutputCacheLocation locationValue =
                outputCacheProfile.Location;

            // Set the Location property to null.
            outputCacheProfile.Location =
                System.Web.UI.OutputCacheLocation.Server;

// </Snippet5>



// <Snippet7>

            // Get the current SqlDependency.
            String sqlDependencyValue =
                outputCacheProfile.SqlDependency;

            // Set the SqlDependency.
            outputCacheProfile.SqlDependency =
                string.Empty;

// </Snippet7>

// <Snippet8>

            // Get the current VaryByParam.
            String varyByParamValue =
                outputCacheProfile.VaryByParam;

            // Set the VaryByParam.
            outputCacheProfile.VaryByParam =
                string.Empty;

// </Snippet8>

// <Snippet9>

            // Get the current VaryByCustom.
            String varyByCustomValue =
                outputCacheProfile.VaryByCustom;

            // Set the VaryByCustom.
            outputCacheProfile.VaryByCustom =
                string.Empty;

// </Snippet9>

// <Snippet10>

            // Get the current Duration.
            Int32 durationValue =
                outputCacheProfile.Duration;

            // Set the Duration property to 0.
            outputCacheProfile.Duration = 0;

// </Snippet10>

// <Snippet11>

            // Get the current Name.
            String nameValue =
                outputCacheProfile.Name;

            // Set the Name.
            outputCacheProfile.Name =
                string.Empty;

// </Snippet11>

// <Snippet12>

            // Get the current Enabled.
            Boolean enabledValue =
                outputCacheProfile.Enabled;

            // Set the Enabled.
            outputCacheProfile.Enabled =
                false;

// </Snippet12>
        }