diff --git a/src/MusicStore/CopyAspNetLoader.cmd b/src/MusicStore/CopyAspNetLoader.cmd index 7ce130d8aa..b29af40af1 100644 --- a/src/MusicStore/CopyAspNetLoader.cmd +++ b/src/MusicStore/CopyAspNetLoader.cmd @@ -1,8 +1,8 @@ REM copy the AspNet.Loader.dll to bin folder -md bin +md wwwroot\bin SET ASPNETLOADER_PACKAGE_BASEPATH=%USERPROFILE%\.dotnet\packages\Microsoft.AspNet.Loader.IIS.Interop REM figure out the path of AspNet.Loader.dll FOR /F %%j IN ('dir /b /o:-d %ASPNETLOADER_PACKAGE_BASEPATH%\*') do (SET AspNetLoaderPath=%ASPNETLOADER_PACKAGE_BASEPATH%\%%j\tools\AspNet.Loader.dll) echo Found AspNetLoader.dll at %AspNetLoaderPath%. Copying to bin\ -copy %AspNetLoaderPath% bin\ \ No newline at end of file +copy %AspNetLoaderPath% wwwroot\bin\ \ No newline at end of file diff --git a/src/MusicStore/Helios.cmd b/src/MusicStore/Helios.cmd index 607ce394fc..eb54a18882 100644 --- a/src/MusicStore/Helios.cmd +++ b/src/MusicStore/Helios.cmd @@ -3,4 +3,4 @@ SET KRE_HOME=%USERPROFILE%\.kre\ REM copy the AspNet.Loader.dll to the bin folder call CopyAspNetLoader.cmd -"%ProgramFiles(x86)%\iis Express\iisexpress.exe" /port:5001 /path:"%cd%" \ No newline at end of file +"%ProgramFiles(x86)%\iis Express\iisexpress.exe" /port:5001 /path:"%cd%\wwwroot" \ No newline at end of file diff --git a/src/MusicStore/Models/ShoppingCart.cs b/src/MusicStore/Models/ShoppingCart.cs index 9ce5c776c9..b228d53e38 100644 --- a/src/MusicStore/Models/ShoppingCart.cs +++ b/src/MusicStore/Models/ShoppingCart.cs @@ -147,22 +147,17 @@ namespace MusicStore.Models } // We're using HttpContextBase to allow access to cookies. - public string GetCartId(HttpContext context) + private string GetCartId(HttpContext context) { - var sessionCookie = context.Request.Cookies.Get("Session"); - string cartId = null; + var cartId = context.Session.GetString("Session"); - if (string.IsNullOrWhiteSpace(sessionCookie)) + if (cartId == null) { //A GUID to hold the cartId. cartId = Guid.NewGuid().ToString(); // Send cart Id as a cookie to the client. - context.Response.Cookies.Append("Session", cartId); - } - else - { - cartId = sessionCookie; + context.Session.SetString("Session", cartId); } return cartId; diff --git a/src/MusicStore/Startup.cs b/src/MusicStore/Startup.cs index eb9a8ea36e..ffe81235d1 100644 --- a/src/MusicStore/Startup.cs +++ b/src/MusicStore/Startup.cs @@ -87,6 +87,10 @@ namespace MusicStore //Add InMemoryCache services.AddSingleton(); + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + // Configure Auth services.Configure(options => { @@ -138,6 +142,9 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // Configure Session. + app.UseSession(); + //Configure SignalR app.UseSignalR(); diff --git a/src/MusicStore/StartupNtlmAuthentication.cs b/src/MusicStore/StartupNtlmAuthentication.cs index 6f553a403d..383fdec1c4 100644 --- a/src/MusicStore/StartupNtlmAuthentication.cs +++ b/src/MusicStore/StartupNtlmAuthentication.cs @@ -90,6 +90,10 @@ namespace MusicStore //Add InMemoryCache services.AddSingleton(); + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + // Configure Auth services.Configure(options => { @@ -97,6 +101,9 @@ namespace MusicStore }); }); + // Configure Session. + app.UseSession(); + //Configure SignalR app.UseSignalR(); diff --git a/src/MusicStore/StartupOpenIdConnect.cs b/src/MusicStore/StartupOpenIdConnect.cs index 5419f2f299..45b02eb034 100644 --- a/src/MusicStore/StartupOpenIdConnect.cs +++ b/src/MusicStore/StartupOpenIdConnect.cs @@ -75,6 +75,10 @@ namespace MusicStore //Add InMemoryCache services.AddSingleton(); + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + // Configure Auth services.Configure(options => { @@ -104,6 +108,9 @@ namespace MusicStore public void Configure(IApplicationBuilder app) { + // Configure Session. + app.UseSession(); + //Configure SignalR app.UseSignalR(); diff --git a/src/MusicStore/project.json b/src/MusicStore/project.json index e7150a2e7a..67b75cd4c9 100644 --- a/src/MusicStore/project.json +++ b/src/MusicStore/project.json @@ -27,9 +27,10 @@ "Microsoft.AspNet.Security.Twitter": "1.0.0-*", "Microsoft.AspNet.Server.IIS": "1.0.0-*", "Microsoft.AspNet.Server.WebListener": "1.0.0-*", + "Microsoft.AspNet.Session": "1.0.0-*", "Microsoft.AspNet.SignalR.Server": "3.0.0-*", "Microsoft.AspNet.StaticFiles": "1.0.0-*", - "Microsoft.Framework.Cache.Memory": "1.0.0-*", + "Microsoft.Framework.Cache.Distributed": "1.0.0-*", // For Session. "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*", "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*", "Microsoft.Framework.Logging.Console": "1.0.0-*" diff --git a/test/E2ETests/E2ETests.kproj b/test/E2ETests/E2ETests.kproj index d0a6624fbc..9c0d9e947a 100644 --- a/test/E2ETests/E2ETests.kproj +++ b/test/E2ETests/E2ETests.kproj @@ -1,4 +1,4 @@ - + 14.0 @@ -14,4 +14,9 @@ 2.0 - + + + + + + \ No newline at end of file diff --git a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs index 9eb4e379b8..fa0bb5929f 100644 --- a/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs +++ b/test/E2ETests/compiler/shared/Mocks/StartupSocialTesting.cs @@ -111,6 +111,10 @@ namespace MusicStore //Add InMemoryCache services.AddSingleton(); + // Add session related services. + services.AddCachingServices(); + services.AddSessionServices(); + // Configure Auth services.Configure(options => { @@ -118,6 +122,9 @@ namespace MusicStore }); }); + // Configure Session. + app.UseSession(); + //To gracefully shutdown the server - Not for production scenarios app.Map("/shutdown", shutdown => {