Sessions will not work out of the box, you need to do some setup:
Add the nuget package
Microsoft.AspNetCore.Session
In Startup.cs add to
ConfigureServices
1
2
3services.AddSession(options => {
options.IdleTimeout = TimeSpan.FromMinutes(15);
});In Startup.cs add to
Configure
1
app.UseSession();
Then in your controllers you can get and set values, would be best to have
ProjectName
set in a constants file.1
2
3HttpContext.Session.SetString("ProjectName", project.ProjectName);
var projectName = HttpContext.Session.GetString("ProjectName");
Microsoft.AspNetCore.Http
These are the methods available for use in the controller (Version=2.2.0.0)
1 | public static byte[] Get(this ISession session, string key); |