I am using the ASP.NET Core 3.1. I need to set a session inside a action in a controller. I have Added the session in the ConfigureServices() method as:
services.AddSession(options => {
options.IdleTimeout = System.TimeSpan.FromSeconds(3600);
});
Also I have add code to use session in the Configure() method as:
app.UseSession();
In the controller class I am trying to create a session
HttpContext.Session.Set("sessionuser",xxx);
The xxx required is a byte[] unlike the string required in SetString() in .NET CORE 2.2 How to create the byte[] for this? Are there other better options in create sessions ?