I need some help. I have these two methods to save and retrieve a class in a session:
public static class SessionExtensions
{
public static void Set<T>(this ISession session, string key, T value)
{
session.SetString(key, JsonConvert.SerializeObject(value));
}
public static T Get<T>(this ISession session, string key)
{
var value = session.GetString(key);
return value == null ? default(T) : JsonConvert.DeserializeObject<T>(value);
}
}
I need a method to save and retrieve in a session an object of type List , how should I implement for ASP.Net Core?
Thanks.