diff --git a/samples/SessionSample/Startup.cs b/samples/SessionSample/Startup.cs index 5410f886c7..17f68de5ce 100644 --- a/samples/SessionSample/Startup.cs +++ b/samples/SessionSample/Startup.cs @@ -3,7 +3,6 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; -using Microsoft.Framework.Logging.Console; namespace SessionSample { @@ -17,7 +16,7 @@ namespace SessionSample public void ConfigureServices(IServiceCollection services) { services.AddCaching(); - services.AddSessionServices(); + services.AddSession(); } public void Configure(IApplicationBuilder app) @@ -58,4 +57,4 @@ namespace SessionSample }); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Session/CachingServicesExtensions.cs b/src/Microsoft.AspNet.Session/CachingServicesExtensions.cs deleted file mode 100644 index 69ef155018..0000000000 --- a/src/Microsoft.AspNet.Session/CachingServicesExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNet.Session; - -namespace Microsoft.Framework.DependencyInjection -{ - public static class CachingServicesExtensions - { - public static IServiceCollection AddSessionServices(this IServiceCollection collection) - { - return collection.AddTransient(); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Session/SessionMiddlewareExtensions.cs b/src/Microsoft.AspNet.Session/SessionMiddlewareExtensions.cs index 0b28bdb9e5..83585bcb45 100644 --- a/src/Microsoft.AspNet.Session/SessionMiddlewareExtensions.cs +++ b/src/Microsoft.AspNet.Session/SessionMiddlewareExtensions.cs @@ -13,11 +13,6 @@ namespace Microsoft.AspNet.Builder { public static class SessionMiddlewareExtensions { - public static IServiceCollection ConfigureSession([NotNull] this IServiceCollection services, [NotNull] Action configure) - { - return services.ConfigureOptions(configure); - } - public static IApplicationBuilder UseInMemorySession([NotNull] this IApplicationBuilder app, IMemoryCache cache = null, Action configure = null) { return app.UseDistributedSession(new LocalCache(cache ?? new MemoryCache(new MemoryCacheOptions())), configure); diff --git a/src/Microsoft.AspNet.Session/SessionServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Session/SessionServiceCollectionExtensions.cs new file mode 100644 index 0000000000..5c9d9bd9ae --- /dev/null +++ b/src/Microsoft.AspNet.Session/SessionServiceCollectionExtensions.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.AspNet.Session; + +namespace Microsoft.Framework.DependencyInjection +{ + public static class SessionServiceCollectionExtensions + { + public static IServiceCollection AddSession([NotNull] this IServiceCollection services) + { + return services.AddSession(configure: null); + } + + public static IServiceCollection AddSession([NotNull] this IServiceCollection services, Action configure) + { + services.AddTransient(); + + if (configure != null) + { + services.Configure(configure); + } + + return services; + } + } +} \ No newline at end of file