ConfigureSession => AddSession overload
This commit is contained in:
parent
dfaf6bb2ff
commit
2bd83e1589
|
|
@ -36,9 +36,7 @@ namespace SessionSample
|
||||||
// Adds a default in-memory implementation of IDistributedCache
|
// Adds a default in-memory implementation of IDistributedCache
|
||||||
services.AddCaching();
|
services.AddCaching();
|
||||||
|
|
||||||
services.AddSession();
|
services.AddSession(o =>
|
||||||
|
|
||||||
services.ConfigureSession(o =>
|
|
||||||
{
|
{
|
||||||
o.IdleTimeout = TimeSpan.FromSeconds(10);
|
o.IdleTimeout = TimeSpan.FromSeconds(10);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,15 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configures the session.
|
/// Adds services required for application session state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="services">The <see cref="IServiceCollection"/> to configure the services.</param>
|
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
|
||||||
/// <param name="configure">The session options to configure the middleware with.</param>
|
/// <param name="configure">The session options to configure the middleware with.</param>
|
||||||
public static void ConfigureSession(
|
/// <returns>The <see cref="IServiceCollection"/>.</returns>
|
||||||
[NotNull] this IServiceCollection services,
|
public static IServiceCollection AddSession([NotNull] this IServiceCollection services, Action<SessionOptions> configure)
|
||||||
[NotNull] Action<SessionOptions> configure)
|
|
||||||
{
|
{
|
||||||
services.Configure(configure);
|
services.Configure(configure);
|
||||||
|
return services.AddSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -275,8 +275,7 @@ namespace Microsoft.AspNet.Session
|
||||||
{
|
{
|
||||||
services.AddInstance(typeof(ILoggerFactory), loggerFactory);
|
services.AddInstance(typeof(ILoggerFactory), loggerFactory);
|
||||||
services.AddCaching();
|
services.AddCaching();
|
||||||
services.AddSession();
|
services.AddSession(o => o.IdleTimeout = TimeSpan.FromMilliseconds(30));
|
||||||
services.ConfigureSession(o => o.IdleTimeout = TimeSpan.FromMilliseconds(30));
|
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
var client = server.CreateClient();
|
var client = server.CreateClient();
|
||||||
|
|
@ -328,8 +327,7 @@ namespace Microsoft.AspNet.Session
|
||||||
{
|
{
|
||||||
services.AddInstance(typeof(ILoggerFactory), new NullLoggerFactory());
|
services.AddInstance(typeof(ILoggerFactory), new NullLoggerFactory());
|
||||||
services.AddCaching();
|
services.AddCaching();
|
||||||
services.AddSession();
|
services.AddSession(o => o.IdleTimeout = TimeSpan.FromMinutes(20));
|
||||||
services.ConfigureSession(o => o.IdleTimeout = TimeSpan.FromMinutes(20));
|
|
||||||
services.Configure<MemoryCacheOptions>(o => o.Clock = clock);
|
services.Configure<MemoryCacheOptions>(o => o.Clock = clock);
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue