Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement