I am doing a series of tests in ASP.NET MVC Core 1.0 to see if it is convenient to migrate the project from MVC 4 to MVC Core 1.0 many of the errors that came out are already fixed.
I have problems passing the parameters that contain sesionManange
:
sesionManage.cuenta = WAutofactura_Respuesta.email;
sesionManage.devKey = WAutofactura_Respuesta.DevKey;
sesionManage.schema = WAutofactura_Respuesta.Schema;
sesionManage.mobileKey = WAutofactura_Respuesta.MobileKey;
which the problem is this line:
HttpContext.Session["sessionManage"] = sesionManage;
So my question is How can I pass the parameters of the variable sesionManange
to a variable HttpContext.Session
in ASP.NET MVC Core 1.0?
EDIT 1
Investigating a bit more in the session variables I found this method to serialize my model of sesionManange
:
public static class SessionExtensions
{
public static T GetObject<T>(this ISession session, string key)
where T : class
{
var json = session.GetString(key);
if (json == null)
{
return null;
}
return JsonConvert.DeserializeObject<T>(json);
}
public static void SetObject(this ISession session, string key, object value)
{
var json = JsonConvert.SerializeObject(value);
session.SetString(key, json);
}
}
Which marks me errors in GetObject<T>
and SetObject
, this is the error that marks me:
Extension methods must be defined in a top level static class; SessionExtensions is a nested class