Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static class SessionExtensions
{
public static void AddSessionWithStartSession(this IServiceCollection services)
{
services.AddSingleton<ISessionStore, DistributedSessionStoreWithStart>();
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.Cookie.IsEssential = true;
});
services.AddSingleton<IStartSession>(s =>
{
var startSession = new StartSession();
// Add here other actions if more funcionality is needed for session start
startSession.AddToStartSession(s.GetRequiredService<IUrlRefererService>().SetSessionStartRefererUrl);
return startSession;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment