Add following Code in Program.CS : builder.Services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); }); app.UseSession(); In Controller use the following Code: To get the Session: HttpContext.Session.SetString("Name", "John Smith"); To set the Session: ViewBag.Name = HttpContext.Session.GetString(sessionName);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter