imageAzure Cache Redis as Session Store for ASP.NET Core Application

visibility 203 access_time 5 months ago language English

When use Cookie authentication schema in ASP.NET core applications, session data by default is saved in client as Cookies. If the session data (incl. user claims) are big (more than 4090 characters), it can be split into multiple chunks. You can notice that via application identifier cookie: 

  • .AspNetCore.Cookies: chunks-2
  • .AspNetCore.CookiesC1: XXX
  • .AspNetCore.CookiesC2: XXX

Instead of storing session data in client cookies, we can also store the session data in any store that implements ITicketStore. It can be databases, memory cache or distributed memory cache like Redis.

This diagram shows a simple solution of using Azure Cache Redis as session store. The following links can be referenced to implement a solution like this. 

References

Cookie size and cookie authentication in ASP.NET Core - Honza’s Blarg (hajekj.net)

ChunkingCookieManager Class (Microsoft.AspNetCore.Authentication.Cookies) | Microsoft Docs

Session in ASP.NET Core | Microsoft Docs

Matteo's Blog - Implementing a custom ITicketStore for ASP.NET Core Identity (ml-software.ch)

Using Redis Cache for session data storage in ASP.NET Core - Joonas W's blog

copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

comment Comments
No comments yet.
tag Tags

info Info
Image URL
SVG URL
URL