// Copyright (c) .NET Foundation. 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.AspNetCore.Session; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Builder { /// /// Extension methods for adding the to an application. /// public static class SessionMiddlewareExtensions { /// /// Adds the to automatically enable session state for the application. /// /// The . /// The . public static IApplicationBuilder UseSession(this IApplicationBuilder app) { if (app == null) { throw new ArgumentNullException(nameof(app)); } return app.UseMiddleware(); } /// /// Adds the to automatically enable session state for the application. /// /// The . /// The . /// The . public static IApplicationBuilder UseSession(this IApplicationBuilder app, SessionOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return app.UseMiddleware(Options.Create(options)); } } }