Configuring session state
Open the Startup.cs file and add the following statements to the end of the ConfigureServices method, after the call to the AddMvc method: services.AddCaching(); services.AddSession(options => { options.CookieName = ".Packt.QuizWebApp"; options.IdleTimeout = TimeSpan.FromMinutes(10); }); Add the following statements to the end of the Configure method, before and after the call to the UseMvc method, to use the session state and to populate the sample questions: app.UseSession(); // must be added before MVC app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseSampleQuestions(env.MapPath("")); // pass the path to the wwwroot directory