Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

regarding using session in asp.net core

$
0
0

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


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>