From 28dfa0f0c42a926b9666d29d3bb2110b9ff30738 Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Wed, 10 Jun 2015 15:59:48 -0700 Subject: [PATCH] Added SQL Server Cache to the sample. --- samples/SessionSample/Startup.cs | 12 +++++++++++- samples/SessionSample/project.json | 16 ++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/samples/SessionSample/Startup.cs b/samples/SessionSample/Startup.cs index 0eaa898719..38ff8d73f6 100644 --- a/samples/SessionSample/Startup.cs +++ b/samples/SessionSample/Startup.cs @@ -4,6 +4,7 @@ using System; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; +using Microsoft.Framework.Caching.Distributed; using Microsoft.Framework.Caching.Redis; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; @@ -26,11 +27,20 @@ namespace SessionSample // This will override any previously registered IDistributedCache service. //services.AddTransient(); + // Uncomment the following line to use the Microsoft SQL Server implementation of IDistributedCache. + // Note that this would require setting up the session state database. + // This will override any previously registered IDistributedCache service. + //services.AddSqlServerCache(o => + //{ + // o.ConnectionString = "Server=.;Database=ASPNET5SessionState;Trusted_Connection=True;"; + // o.TableName = "Sessions"; + //}); + services.AddSession(); services.ConfigureSession(o => { - o.IdleTimeout = TimeSpan.FromSeconds(30); + o.IdleTimeout = TimeSpan.FromSeconds(10); }); } diff --git a/samples/SessionSample/project.json b/samples/SessionSample/project.json index cf9b17c4b3..4c090e0f1e 100644 --- a/samples/SessionSample/project.json +++ b/samples/SessionSample/project.json @@ -1,16 +1,20 @@ { - "webroot": "wwwroot", - "exclude": "wwwroot/**/*.*", + "commands": { + "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001", + "install-sqlservercache": "Microsoft.Framework.Caching.SqlServer" + }, "dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", "Microsoft.AspNet.Session": "1.0.0-*", "Microsoft.Framework.Caching.Memory": "1.0.0-*", "Microsoft.Framework.Caching.Redis": "1.0.0-*", + "Microsoft.Framework.Caching.SqlServer": "1.0.0-*", "Microsoft.Framework.Logging.Console": "1.0.0-*" }, - "commands": { "web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" }, - "frameworks" : { - "dnx451" : { } - } + "exclude": "wwwroot/**/*.*", + "frameworks": { + "dnx451": { } + }, + "webroot": "wwwroot" }