Web Session and Cache helper class

Web Session and Cache helper
//get key from session  
int someKey1 = d.Web.Helper.Session.Get("someKey"); 
int someKey2 = HttpContext.Current.Session.Get("someKey");

//if key not exists return value from function and insert to cache 
int someKey3 = d.Web.Helper.Session.TryGet("someKey", () => { return 0; }); 
int someKey4 = d.Web.Helper.Session.TryGet("someKey", CreateNewSessionFunction );

//get key from cache 
int someKey1 = d.Web.Helper.Cache.Get("someKey"); 
int someKey2 = HttpRuntime.Cache.Get("someKey");

//if key not exists return value from function and insert to cache 
int someKey3 = d.Web.Helper.Cache.TryGet("someKey", () => { return 0; }); 
int someKey4 = HttpRuntime.Cache.TryGet("someKey", new TimeSpan(1000), CreateNewCacheFunction);

Web Form helper
//get value from HttpContext.Current.Request.QueryString
d.Web.Helper.Form.QueryValue("someKey");
d.Web.Helper.Form.QueryValue("someKey", "",",");
d.Web.Helper.Form.QueryValue("someKey", "yyyyMMdd");

//get value from  HttpContext.Current.Request.Params
d.Web.Helper.Form.PostValue("someKey");
d.Web.Helper.Form.PostValue("someKey", "", ",");
d.Web.Helper.Form.PostValue("someKey", "yyyyMMdd");

https://github.com/dzsoft-ru/d.Web

Добавить комментарий

Loading