i read this article http://www.c-sharpcorner.com/article/how-to-use-session-in-asp-net-core/
i saw they add session related code twice
public void ConfigureServices(IServiceCollection services) { services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(1);//You can set Time }); services.AddMvc(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
in configure service function they add this
services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(1);//You can set Time });
again in Configure function they add app.UseSession();
tell me why we need to add twice session in configure function. thanks