Пытаюсь добавить в сессию строчку:
HttpContext.Session.SetString("Train", "wewew");
В ConfigureServices добавил:
services.AddDistributedMemoryCache();
services.AddSession();
В Configure добавил:
app.UseAuthentication();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
А ошибку выдает:
An unhandled exception occurred while processing the request.
InvalidOperationException: Session has not been configured for this application or request.
Microsoft.AspNetCore.Http.DefaultHttpContext.get_Session()