Hi,
I have an extension method for sessions from MS docs
using Microsoft.AspNetCore.Http; using Newtonsoft.Json; 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'm using that to store values in a class.
It's all good getting the values from controller, but is it possible to read the session from Javascript?
I read this but it's not for Core 2.0
I use this to get data from controller:
var Partner = HttpContext.Session.Get<PartnerData>("Partner");