If you find yourself within a Controller
you can do it with the HttpContext.Session.Set<T>(key, data);
method, assuming we want to add the orderView
object:
string keyOrderView = "orderView";
HttpContext.Session.Set<OrderVM>(keyOrderView, orderView);
Now, to read the information of that session variable is with the HttpContext.Session.Get<T>(key);
method:
OrderVM ordenes = HttpContext.Session.Get<OrderVM>(keyOrderView);
In this official Microsoft document ( in English ) explains how to handle the state and session of the application in ASP.NET Core.