Exemple #1
0
        public static void p5_web_cache_set(ApplicationContext context, ActiveEventArgs e)
        {
            // Retrieving for how long the value should be set in cache, before removed
            var minutes = e.Args.GetExChildValue("minutes", context, 30);

            // We must untie [minutes] to avoid having multiple sources for our iteration below.
            e.Args ["minutes"]?.UnTie();

            // Settings cache value
            XUtil.Set(context, e.Args, delegate(string key, object value) {
                if (value == null)
                {
                    // Removal
                    HttpContext.Current.Cache.Remove(key);
                }
                else
                {
                    // Setting or updating
                    HttpContext.Current.Cache.Insert(
                        key,
                        value,
                        null,
                        DateTime.Now.AddMinutes(minutes),
                        System.Web.Caching.Cache.NoSlidingExpiration);
                }
            }, "minutes");
        }
 public void p5_web_viewstate_set(ApplicationContext context, ActiveEventArgs e)
 {
     XUtil.Set(context, e.Args, delegate(string key, object value) {
         if (value == null)
         {
             // Removal
             ViewState.Remove(key);
         }
         else
         {
             // Setting or updating
             ViewState[key] = value;
         }
     });
 }
Exemple #3
0
 public static void p5_web_context_set(ApplicationContext context, ActiveEventArgs e)
 {
     XUtil.Set(context, e.Args, delegate(string key, object value) {
         if (value == null)
         {
             // Removal
             HttpContext.Current.Items.Remove(key);
         }
         else
         {
             // Setting or updating
             HttpContext.Current.Items[key] = value;
         }
     });
 }
 public static void p5_web_header_set(ApplicationContext context, ActiveEventArgs e)
 {
     XUtil.Set(context, e.Args, delegate(string key, object value) {
         if (value == null)
         {
             // Removal
             HttpContext.Current.Response.Headers.Remove(key);
         }
         else
         {
             // Setting or updating
             HttpContext.Current.Response.AddHeader(key, Utilities.Convert <string> (context, value));
         }
     });
 }
Exemple #5
0
 public static void p5_web_cookie_set(ApplicationContext context, ActiveEventArgs e)
 {
     XUtil.Set(context, e.Args, delegate(string key, object value) {
         if (value == null)
         {
             // Removal
             var httpCookie = HttpContext.Current.Response.Cookies[key];
             if (httpCookie != null)
             {
                 httpCookie.Expires = DateTime.Now.Date.AddDays(-1);
             }
         }
         else
         {
             // Setting or updating
             HttpContext.Current.Response.Cookies.Add(CreateCookieFromNode(e.Args, context, key, value));
         }
     }, "duration", "http-only");
 }