{"id":4027,"date":"2017-09-20T08:45:52","date_gmt":"2017-09-20T15:45:52","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=4027"},"modified":"2025-06-13T19:40:26","modified_gmt":"2025-06-14T02:40:26","slug":"distributed-session-aspnet-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/","title":{"rendered":"Distributed session management in ASP.NET Core with Couchbase"},"content":{"rendered":"<div class=\"paragraph\">\n<p>Distributed session is a way for you to store your session state outside of your ASP.NET Core application. Using Couchbase to store session state can help you when you need to scale your web site, especially if you don\u2019t want to use <a href=\"https:\/\/www.couchbase.com\/blog\/sticky-sessions\/\">sticky sessions<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>You can follow along with the code samples I\u2019ve created, available on <a href=\"https:\/\/github.com\/couchbaselabs\/blog-source-code\/tree\/master\/Groves\/081AspNetCoreSession\/src\/AspNetDistributedSession\">GitHub<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><em>Note that Couchbase.Extensions.Session is a beta release at the time of this writing.<\/em><\/p>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_review_of_session\">What is session state?<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Session state is simply a way to store data for a particular user. Typically, a token is stored in a user cookie, and that token acts as a key to some set of data on the server side.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<h2 id=\"_review_of_session\">How to enable session in ASP.NET<\/h2>\n<p>If you\u2019re familiar with ASP.NET or ASP Classic, this is done using <code>Session<\/code>. All the cookie work is done behind the scenes, so you simply use <code>Session<\/code> as a dictionary to store and retrieve whatever data you want.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">if(Session[\"IsLoggedIn\"] = false)\r\n    Session[\"Username\"] = \"matt\";<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>By default, in ASP.NET and ASP Classic, this information is stored in memory, as part of the web application process.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>In ASP.NET Core, you can also opt-in to this by configuring session with <code>AddSession<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>First, in Startup.cs, in the <code>Configure<\/code> function, tell ASP.NET Core to use session:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">app.UseSession();<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>Then, in the <code>ConfigureServices<\/code> function, use <code>AddSession<\/code> to add a session provider service.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">services.AddDistributedMemoryCache();\r\nservices.AddSession();<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>(This will use the default session settings, see the <a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/app-state?tabs=aspnetcore2x\">ASP.NET Core documentation<\/a> for more information).<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2> What is session management in ASP.NET Core? <\/h2>\n<div class=\"paragraph\"> Session management in ASP.NET Core is a way to store and manage user-specific data across multiple requests within a web application. It uses a session token, typically stored in a cookie, to associate the user with their data on the server. Sessions can be stored in memory, distributed systems, or databases, enabling scalable and efficient handling of user state in applications. <\/p>\n<p>A distributed session is a way for you to store your session state outside of your ASP.NET Core application. Using Couchbase to store session state can help you when you need to scale your web site, especially if you don\u2019t want to use sticky sessions. <\/p><\/div>\n<h2 id=\"_why_distributed_session\">Why distributed session management?<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>However, if you are scaling out your web application with multiple web servers, you\u2019ll have to make some decisions about session. If you continue to use in-process session, then you must configure sticky sessions (the first web server that a user hits is the one they will &#8220;stick&#8221; with for subsequent requests). This has some potential downsides (see <a href=\"https:\/\/serverfault.com\/questions\/46307\/what-is-the-downside-to-sticky-sessions-with-load-balancers\">this thread on ServerFault<\/a> and <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/2009.06.asp.aspx\">this article on Microsoft\u2019s TechNet magazine<\/a>).<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>If you don\u2019t want to use sticky sessions, then you can\u2019t use the in-process session option. You\u2019ll instead need to use a distributed session. There are a lot of options for where to put session data, but Couchbase\u2019s memory-first architecture and flexible scaling capabilities make it a good choice.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_using_distributed_session_in_asp_net_core\">Using distributed session in ASP.NET Core<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Before you start writing code, you\u2019ll need a Couchbase Server cluster running with a bucket (I named mine &#8220;sessionstore&#8221;). You\u2019ll also need to create a user with Data Reader and Data Writer permission on the bucket (I also called my user &#8220;sessionstore&#8221; just to keep things simple).<\/p>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_adding_couchbase_extensions_session\">Adding Couchbase.Extensions.Session<\/h3>\n<div class=\"paragraph\">\n<p>Now, open up your ASP.NET Core application in Visual Studio. (I created a new ASP.NET Core MVC app, which <a href=\"https:\/\/github.com\/couchbaselabs\/blog-source-code\/tree\/master\/Groves\/081AspNetCoreSession\/src\/AspNetDistributedSession\">you can find on GitHub<\/a>). Next, with NuGet, install the Couchbase.Extensions.Session library:<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li>Use the NuGet UI (see below), or<\/li>\n<li><code>Install-Package Couchbase.Extensions.Session -Version 1.0.0-beta2<\/code> with the Package manager, or<\/li>\n<li><code>dotnet add package Couchbase.Extensions.Session --version 1.0.0-beta2<\/code> with the dotnet command line<\/li>\n<\/ul>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/08101-Couchbase-Extensions-with-NuGet.png\" alt=\"Couchbase Extensions with NuGet\" \/><\/span><\/p>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_configuring_couchbase\">Configuring Couchbase<\/h3>\n<div class=\"paragraph\">\n<p>To configure the session provider, you\u2019ll be writing some code that looks familiar if you\u2019ve been following along in this Couchbase.Extensions series.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>The <code>ConfigureServices<\/code> method in Startup.cs is where you\u2019ll be adding configuration code.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>First, use <code>AddCouchbase<\/code>, which is done with the <a href=\"https:\/\/www.couchbase.com\/blog\/dependency-injection-aspnet-couchbase\/\">Dependency Injection<\/a> extension.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>After that, setup the distributed cache for Couchbase with <code>AddDistributedCouchbaseCache<\/code>, which I covered in a blog post on <a href=\"https:\/\/www.couchbase.com\/blog\/distributed-caching-aspnet-couchbase\/\">distributed caching<\/a>.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">services.AddCouchbase(opt =&gt;\r\n{\r\n    opt.Servers = new List&lt;Uri&gt; { new Uri(\"https:\/\/localhost:8091\") };\r\n});\r\n\r\nservices.AddDistributedCouchbaseCache(\"sessionstore\", \"password\", opt =&gt; { });<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>Finally, configure Couchbase as a session store with <code>AddCouchbaseSession<\/code>.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">services.AddCouchbaseSession(opt =&gt;\r\n{\r\n    opt.CookieName = \".MyApp.Cookie\";\r\n    opt.IdleTimeout = new TimeSpan(0, 0, 20, 0);\r\n});<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>You can configure the idle timeout (how long until the session expires after not being used), the cookie name, and more, if you need to. In the above example, I set the timeout to 20 minutes and the cookie name to &#8220;.MyApp.Cookie&#8221;.<\/p>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_writing_to_a_distributed_session\">Writing to a distributed session<\/h3>\n<div class=\"paragraph\">\n<p>To access Session data, you can use <code>HttpContext.Session<\/code>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>First, I want to write something to session. In an <code>About<\/code> controller action, I used the <code>SetObject<\/code> method:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">public IActionResult About()\r\n{\r\n    HttpContext.Session.SetObject(\"sessionkey\", new\r\n    {\r\n        Name = \"Matt\",\r\n        Twitter = \"@mgroves\",\r\n        Guid = DateTime.Now\r\n    });\r\n\r\n    ViewData[\"Message\"] = \"I put a value in your session. Click 'Contact' to see it.\";\r\n\r\n    return View();\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>From this point on, whenever you click to view the &#8220;About&#8221; page, a new value will be stored in session with the key &#8220;sessionkey&#8221;. If you switch over to Couchbase Console, you can see the data being stored.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/08102-distributed-session-document-in-couchbase.png\" alt=\"Distributed session document in Couchbase\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>Note that a user\u2019s session is represented by a single document. So, if I were to insert another session value (as below), that value would be stored in the same document.<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">HttpContext.Session.SetObject(\"sessionkey2\", new\r\n{\r\n    Address = \"123 Main St\",\r\n    City = \"Lancaster\",\r\n    State = \"OH\"\r\n});<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>The resultant document would look like:<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/08103-two-distributed-session-keys.png\" alt=\"Two distributed session keys\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>You should be careful not to go crazy with the amount of data you put into session, because Couchbase documents are limited to 20mb.<\/p>\n<\/div>\n<\/div>\n<div class=\"sect2\">\n<h3 id=\"_reading_from_a_distributed_session\">Reading from a distributed session<\/h3>\n<div class=\"paragraph\">\n<p>To get a value out of session, you can use <code>GetObject<\/code> and supply the session key. In the sample code, I did this in the <code>Contact<\/code> action:<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight decode:true\"><code class=\"language-C#\">public IActionResult Contact()\r\n{\r\n    ViewData[\"Message\"] = HttpContext.Session.GetObject&lt;dynamic&gt;(\"sessionkey\");\r\n\r\n    return View();\r\n}<\/code><\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>After you visit the &#8220;About&#8221; page at least once, go to the &#8220;Contact&#8221; page. You should see the session object printed out to the page.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/08104-output-from-distributed-session.png\" alt=\"Output to ASP.NET from distributed session\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>That\u2019s pretty much it. There are some other relatively self-evident methods available on <code>Session<\/code>. They are also <a href=\"https:\/\/docs.microsoft.com\/en-us\/aspnet\/core\/fundamentals\/app-state?tabs=aspnetcore2x\">outlined in the ASP.NET Core documentation<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>One more thing: I named the cookie (&#8220;.MyApp.Cookie&#8221;). You can view this cookie in the browser of your choice. In Chrome, use Ctrl+Shift+I and navigate to the &#8220;Application&#8221; tab. You will see the cookie and its value.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p><span class=\"image\"><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2017\/09\/08105-session-cookie.png\" alt=\"Session cookie\" \/><\/span><\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>You generally don\u2019t need to know this detail in your day-to-day as an ASP.NET Core developer, but it\u2019s good to know how things work just in case.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"sect1\">\n<h2 id=\"_summary\">Summary<\/h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The distributed session extension for Couchbase is another tool in your box for helping to scale your ASP.NET Core applications. These handy .NET extensions help to demonstrate how Couchbase is the <a href=\"https:\/\/www.couchbase.com\/products\/data-platform\/\">engagement database<\/a> platform that you need.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>If you have questions or comments on Couchbase Extensions, make sure to check out the <a href=\"https:\/\/github.com\/couchbaselabs\/Couchbase.Extensions\">GitHub repository<\/a> or the <a href=\"https:\/\/www.couchbase.com\/forums\/c\/net-sdk\/6\/\">Couchbase .NET SDK forums<\/a>.<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>And please reach out to me with questions on all things .NET and Couchbase by leaving a comment below or finding me on <a href=\"https:\/\/twitter.com\/mgroves\">Twitter @mgroves<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Distributed session is a way for you to store your session state outside of your ASP.NET Core application. Using Couchbase to store session state can help you when you need to scale your web site, especially if you don\u2019t want [&hellip;]<\/p>\n","protected":false},"author":71,"featured_media":4028,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1811,10126,1816],"tags":[1239,2052,2024],"ppma_author":[8937],"class_list":["post-4027","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-asp-dotnet","category-couchbase-server","tag-caching","tag-extensions","tag-session"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Distributed Session Management in ASP.NET Core | Couchbase<\/title>\n<meta name=\"description\" content=\"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Distributed session management in ASP.NET Core with Couchbase\" \/>\n<meta property=\"og:description\" content=\"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-20T15:45:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T02:40:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"633\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Matthew Groves\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mgroves\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Matthew Groves\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\"},\"author\":{\"name\":\"Matthew Groves\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58\"},\"headline\":\"Distributed session management in ASP.NET Core with Couchbase\",\"datePublished\":\"2017-09-20T15:45:52+00:00\",\"dateModified\":\"2025-06-14T02:40:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\"},\"wordCount\":1087,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg\",\"keywords\":[\"caching\",\"extensions\",\"session\"],\"articleSection\":[\".NET\",\"ASP.NET\",\"Couchbase Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\",\"name\":\"Distributed Session Management in ASP.NET Core | Couchbase\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg\",\"datePublished\":\"2017-09-20T15:45:52+00:00\",\"dateModified\":\"2025-06-14T02:40:26+00:00\",\"description\":\"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg\",\"width\":1200,\"height\":633},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Distributed session management in ASP.NET Core with Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58\",\"name\":\"Matthew Groves\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"caption\":\"Matthew Groves\"},\"description\":\"Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.\",\"sameAs\":[\"https:\/\/crosscuttingconcerns.com\",\"https:\/\/x.com\/mgroves\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/matthew-groves\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Distributed Session Management in ASP.NET Core | Couchbase","description":"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Distributed session management in ASP.NET Core with Couchbase","og_description":"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.","og_url":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2017-09-20T15:45:52+00:00","article_modified_time":"2025-06-14T02:40:26+00:00","og_image":[{"width":1200,"height":633,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg","type":"image\/jpeg"}],"author":"Matthew Groves","twitter_card":"summary_large_image","twitter_creator":"@mgroves","twitter_misc":{"Written by":"Matthew Groves","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/"},"author":{"name":"Matthew Groves","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58"},"headline":"Distributed session management in ASP.NET Core with Couchbase","datePublished":"2017-09-20T15:45:52+00:00","dateModified":"2025-06-14T02:40:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/"},"wordCount":1087,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg","keywords":["caching","extensions","session"],"articleSection":[".NET","ASP.NET","Couchbase Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/","name":"Distributed Session Management in ASP.NET Core | Couchbase","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg","datePublished":"2017-09-20T15:45:52+00:00","dateModified":"2025-06-14T02:40:26+00:00","description":"Learn about distributed session management in ASP.NET Core with Couchbase. Scale your web apps seamlessly with our memory-first architecture and tools.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2017\/09\/081-hero-congress-session.jpg","width":1200,"height":633},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/distributed-session-aspnet-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Distributed session management in ASP.NET Core with Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58","name":"Matthew Groves","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54","url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","caption":"Matthew Groves"},"description":"Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.","sameAs":["https:\/\/crosscuttingconcerns.com","https:\/\/x.com\/mgroves"],"url":"https:\/\/www.couchbase.com\/blog\/author\/matthew-groves\/"}]}},"authors":[{"term_id":8937,"user_id":71,"is_guest":0,"slug":"matthew-groves","display_name":"Matthew Groves","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","author_category":"","last_name":"Groves","first_name":"Matthew","job_title":"","user_url":"https:\/\/crosscuttingconcerns.com","description":"Matthew D. Groves is a guy who loves to code.  It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything.  He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s.  He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community.  He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/4027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=4027"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/4027\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/4028"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=4027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=4027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=4027"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=4027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}