SHARE
TWEET

Untitled

a guest Feb 20th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static class SessionExtensions
  2. {
  3.     public static void Set<T>(this ISession session, string key, T value)
  4.     {
  5.         session.SetString(key, JsonConvert.SerializeObject(value));
  6.     }
  7.  
  8.     public static T Get<T>(this ISession session, string key)
  9.     {
  10.         var value = session.GetString(key);
  11.  
  12.         return value == null ? default(T) :
  13.             JsonConvert.DeserializeObject<T>(value);
  14.     }
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top