コード例 #1
0
        public JsonResult CacheSet(SiteCacheIM vm)
        {
            if (!ModelState.IsValid)
            {
                var errorMessage = GetModelErrorMessage();
                AR.Setfailure(errorMessage);
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }

            try
            {
                var       xmlFile = Server.MapPath("~/Config/GlobalSettings.config");
                XDocument doc     = XDocument.Load(xmlFile);

                var item = doc.Descendants("Settings").FirstOrDefault();

                item.Element("EnableCaching").SetValue(vm.EnableCaching);
                item.Element("CacheDuration").SetValue(vm.CacheDuration);

                doc.Save(xmlFile);

                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
            catch (Exception ex)
            {
                AR.Setfailure(ex.Message);
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
        }
コード例 #2
0
        public ActionResult CacheSet()
        {
            var cfe = SettingsManager.Site;

            var vm = new SiteCacheIM
            {
                CacheDuration = cfe.CacheDuration,
                EnableCaching = cfe.EnableCaching
            };

            return(View(vm));
        }